What is the easiest way to distribute a PHP extension written in C
Asked Answered
H

2

6

I created an extension for djondb, it's a wrapper of the library which is a C++ Library, I compiled it and it's available to be downloaded from djondb site, I'm not an expert on PHP and I've been having some problems with the distribution, mainly I realize that I need to do each compilation for each platform and create an installer for each one, which is time consuming, what I want it's a to ditribute the source code and allow the user to install it in the easiest way,

What I already tried:

  1. Using phpize, configure, make, sudo make install the user can install the library very easy on Linux and Mac, the problem with this is that users need to have g++, make, etc installed on their computers, and this process of installation does not work on Windows.
  2. Compile for each platform (Linux x86, x64, Mac, Windows, etc), and upload each tar.gz to the site, the user download it and place each file in the correct folder. the problem here is that the configuration is too manual and the users tend to miss some step, and it's not user friendly. The other problem is that I need to compile each version using a virtual machine and that's time consuming. (Now I'd to include versions for PHP 5.3 and 5.4, this means 8 virtual machines to create all the binaries)
  3. I tried to create an account on PEAR but the registration screen always said that I dont need an account for the purpose I'm creating... (seems that it's a common problem in PEAR system but didnt find how to create the account to propose the package).
  4. Did a proposal on PECL but nobody answered to the mailing list, seems that it's very common too.

So I'm stuck at this moment with the 1 and 2 ways to distribute, what is the best way to distribute a PHP extension that is created using C++ in a user friendly manner and easy to install?

Thanks in advance, you can see the code of the project at https://github.com/djondb/djondb_phpext if you have more questions about how the project is structured or the full explanation of the phpize/configure/make process.

Hypothesis answered 27/1, 2013 at 18:37 Comment(1)
b.t.w I think the way github.com/nicolasff/phpredis gives documentation is the way to go.Litton
L
2

As a PHP developer who maintains the extensions we use in our company, it is PERFECTLY fine to give only the source code and expect the users to compile it on their machines.

If you want to be nice, compiling a version for each machine you support yourself, is also an accepted way (See Zend for example) and leave it somewhere easy to download (like sourceforge/github etc).

Then, just listen to the users and improve your (release) system as you go.

Litton answered 27/1, 2013 at 19:49 Comment(2)
Thanks for your answer, I will give you the accepted answer for been a developer who clarify that it's perfectly fine to distribute the source and expect the users to do their job, I didn't know it was the typical deployment solution and I was expecting that php provides a more user friendly way to work with this.Hypothesis
not PHP per se, more like the packaging/distribution system linux and windows have. If u have spoiled users (on Ubuntu, for example) than sudo apt-get install YOUREXTENSION would be nicer. But really, it is not necessary. PECL/PEAR where supposed to be the distro way of PHP, I forgot the last time I used them.Litton
F
3

Take the middle road: Distribute the source for Linux / OS X users, who can build it themselves, and offer compiled DLLs for Windows users. That will at least limit the number of versions you need to compile.

Fatidic answered 27/1, 2013 at 19:43 Comment(1)
Thanks for your answer, it's nice to know that I was doing it right and in a PHP's way.Hypothesis
L
2

As a PHP developer who maintains the extensions we use in our company, it is PERFECTLY fine to give only the source code and expect the users to compile it on their machines.

If you want to be nice, compiling a version for each machine you support yourself, is also an accepted way (See Zend for example) and leave it somewhere easy to download (like sourceforge/github etc).

Then, just listen to the users and improve your (release) system as you go.

Litton answered 27/1, 2013 at 19:49 Comment(2)
Thanks for your answer, I will give you the accepted answer for been a developer who clarify that it's perfectly fine to distribute the source and expect the users to do their job, I didn't know it was the typical deployment solution and I was expecting that php provides a more user friendly way to work with this.Hypothesis
not PHP per se, more like the packaging/distribution system linux and windows have. If u have spoiled users (on Ubuntu, for example) than sudo apt-get install YOUREXTENSION would be nicer. But really, it is not necessary. PECL/PEAR where supposed to be the distro way of PHP, I forgot the last time I used them.Litton

© 2022 - 2024 — McMap. All rights reserved.