Compile PHP using shared option and directory location - php

I cannot figure out the proper ./configure options to use when giving the configure command if I would like to have something be shared (thus creating an .so extension) as well as stating a directory where required libraries are.
Example:
--with-openssl=shared will create a .so file
--with-openssl=/home/username/local will compile directly into the php build.
How do I state both? I see this nowhere in the php docs.
I am installing on a linux Ubuntu.

Well, I found it through trial and error as well as a few other posts of people going through different troubles that had their ./configure commands visible.
In my example case there are two flags you need:
--with-openssl=shared --with-openssl-dir=/home/username/local
In other instances there is no extension-name-dir flag, so you do comma separated values:
--with-cron=shared,/home/username/local
I could find no easy way to tell you which ones are which, but trial and error got me through these two that I needed. In the case of GD you actually need as many as four separate ones for the needed library support:
--with-gd=shared --with-jpeg-dir=/home/username/usr --with-png-dir=/home/username/usr --with-freetype-dir=/home/username/usr
Hope this helps someone else, I could find no other discussions about this issue (hard to believe there was no SO answers already).

Related

What php modules are used by my app

Is there a way I can find out what modules are being used by my php application without going through thousands of lines of code?
I can get the whole list of PHP modules on current server via php -m, but I want to know if there is any way to find out modules required by my app in particular.
There is a PEAR package called PHP_CompatInfo that does something like that:
Find out the minimum version and the extensions required for a piece of code to run
It's marked as no longer maintained, so there might be some problems using it with recent versions of PHP
You should look into using get_loaded_extensions() or extension_loaded().

Can I compile Ming for PHP/Windows?

Where can I find instructions for compiling Ming? Google is confused and thinks I am looking for pages about MinGW (the C++ lib for Windows) when in fact I want this:
http://www.php.net/manual/en/book.ming.php (a PHP lib for creating SWF files)
I currently have Wamp Server installed. I checked the option php_ming, but Ming still did not work. I finally found out that even though Wamp is adding the right line to the php.ini file, the actual file it refers to "php_ming.dll" does not exist on my computer.
It also does not appear to exist on the Internet (at least not on any safe looking website). So, apparently, I must compile it from scratch. Compiling in C is very difficult for me, because I do not understand why so many different types of files and configuration options are required, which files to get, where to get them, and where to put them.
I get DOT C files (programs) and DOT H files (includes), but I quickly get lost with DOT O files, "linker" files, command line options - and all the specifics which must be exactly right for any compile to work. For this reason, I am looking for instructions on how to compile Ming for PHP/Windows. Where can I find this?

PHP --with-curl

I need to install cURL. PHP's official website writes:
To use PHP's cURL support you must also compile PHP --with-curl[=DIR] where DIR is the location of the directory containing the lib and include directories.
But I've seen people doing it like that:
<?php
// some text...
--with-curl
// some text...
?>
Which one should I choose?
Writing --with-curl arbitrarily in the middle of your code does nothing except potentially cause syntax errors.
The code that you show does not make any sense, is not valid PHP code and the PHP interpreter will throw an error. If you want to use curl you have to install it.
The second option isn't valid, as others have mentioned. The only way to add modules (in this case, the one that adds curl support) is to compile PHP with those modules active. That is what --with-php does - tells PHP to compile with curl.
Now, the source code for some packages do allow you to add that to one of the compiling config files, and it often takes the same form as the command line switch. I'm not sure if PHP has that option (never needed to compile it by hand), but if it does, it's not going to be in a PHP file.
If you run a version of Linux, you also have the option of installing php-curl/php5-curl from your distribution's repository. Doing it that way saves the headache of compiling it yourself and remembering what you need to turn on and off, and handles dependency needs.
Ultimately, though, how you go about installing it or adding modules depends on your platform, skill level, and overall needs and comfort level.

Where to get php_perl.dll while pecl4win is down?

I need to call a Perl script from a PHP file, and I've gotten as far as know that I need the Perl class, and that it's in the php_perl.dll extension. I've also downloaded the php_perl package from PECL, but as you know, it's just the source and needs to be compiled. I don't work in C, so compiling it's not really an option -- I tried downloading Visual Studio Express but I still can't seem to make it happen.
So I really need php_perl.dll, but http://pecl4win.php.net/ext.php/php_perl.dll just tells me that "The pecl4win build box is temporarily out of service. We're preparing a new build system." Surely there must be SOMEWHERE else I can get the DLL, but I can't seem to find it. Every link I find seems to either be someone else looking for it, or a warez-looking site that wants you to give them your credit card info.
Thanks...
---- Nick
The Internet Archive Wayback Machine results look promising, perhaps one of the links will lead you to the file (although they often take such binary files out of the archive).
EDIT: I was able to get the DLL for the older branch php-5.0.5 (5_0) that way and uploaded it here (removed). Or try the direct link.
Looking for the newer branch php-5.1.6 (5_1) however gave no results so far, I checked the 4 most recent dates.
EDIT2: Found another working link for branch php-5.1.2.
The sidebar
says to use the following repository until the new buildsystem is online:
http://downloads.php.net/pierre/

Libraries other than ZipArchive for creating pkzip archives in PHP?

I'm in the process of writing some epub creation functionality using php5. Currently I am attempting to use ZipArchive but have run into a couple annoyances with it. First of all, there is no functionality to set the compression level. Second of all, ZipArchive::addFile() seems to fail silently and create a corrupt archive whenever I use it. I have been using file_get_contents() + ZipArchive::addFromString() instead but would prefer to just use the documented function for adding files.
I will not post code samples unless someone would really like to help me debug this issue, but rather I'm wondering if there are any other libraries for creating zip (pkzip) archives in PHP that you would recommend. So far, I have seen PclZip, whose site does not seem to be loading, but not much else. I have also considered using exec() + zip (unix command). This code will only run on this one particular linux box so portability is not an issue.
Thanks in advance for any suggestions!
PCLZip is pretty good alternative, with zlib as its only dependency, if you can get access to the site. It's probably temporary, it was certainly accessible between Christmas and New Year.
It's also pretty efficient, even in comparison with ZipArchive
EDIT
You say that you've had problems with ZipArchive's addFile() method. Is this in a Windows environment, or on your Linux server? I know that there have been a few buggy releases of the php_zip library on Win32 that can give this problem, although the latest versions seem OK, and I've not encountered the same problem on other platforms (even the WIN64 version).
I'd use exec() and the Unix command. A native-to-the-system way to solve the problem - the unix utils will always be a step or two ahead from their PEAR counterparts.

Categories