What is the best way to build php from source CentOS - php

I am building php from source on a new CentOS box and as usual I have to wrangle up all the various configuration options I might need. This gets tricky because there are various extensions that I want and certain options that I always for get to put in the .configure script. Not only that but PHP 5.3 has has different defaults for various options.
Is there an interactive or annotated version of the configure script somewhere or a good set of defaults to reference?
Thanks!

Grab the existing PHP SRPM, update the spec with the new version, release, and tarball, and rebuild.

Related

PHP installation source

often we get a pack and made configure as habitual. I'm trying to set a dev enviorment with Apache (already installed), SQL and PHP. Curiosly, the PHP introdue a source tree slightly different of the habitual, with a collection of files named Makefile.global, Makefile.gcov, Makefile.objects and Makefile.fragments (or something as, relying version). The ask simple: what is this 'new concept' and how to make it effectively.
Thanks.

Does PHP have a built-in means of determining the oldest PHP version compatible with a given PHP script? Or will it ever?

I wish to be able to do something like:
php --determine-oldest-supported-php-version test.php
And get this output:
7.2
That is, the php binary checks test.php for all function calls or syntax used, and then spits out the oldest version of PHP which would be able to run the script.
The purpose would be for me to create a script which goes through all the .php files in my library/framework and figures out which version of PHP I should consider to be the "oldest supported version".
Currently, I'm doing this manually. Whenever I knowingly use a new feature, function or syntax, I bump up a variable to "7.4" or whatever, and then compare the currently used PHP version against that on runtime. This is not ideal, as you can imagine, and I could very well forget to bump up this value or bump it up too much, or too little, etc.
It would be much nicer to be able to determine this automatically, with such a feature in PHP itself.
I have of course looked through the list of options and PHP has no such feature as far as I can tell. Since I basically answered my own question right away, are there any plans on such a feature in the future?
The only guarantee given is that PHP will remain compatible within the same major version.
You may be interested in looking at the article
Why You Should Be Using Supported PHP Versions.
The tool you are looking for is the GitHub project
PHP_CodeSniffer,
further described in the article
PHPCompatibility update.
You may run it using a command such as:
phpcs --standard=PHPCompatibility --runtime-set testVersion 5.4 <path-of-your-php-files>

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().

How to compile php without unneeded functions to a single file?

I'm trying to create a very small php binary for a specific use. I don't need many of the functions and classes included in commong php. How can I do this?
Thanks.
Checkout php source form svn or download source dist on php.net and build it using manual. It is better to do it on nix systems or compile PHP with cygwin on Win. You can easy configure php extensions when building it and exclude some of it using configure script. If you need more specific configurations you should know how Autotools works couse php uses it.

Can you use scons to build PHP extensions?

The standard way of writing PHP extensions is to use autoconf/automake alongside a script called phpize, which seems to generate your autoconf configuration based on a template that's specific to your PHP environment. This let's it build the PHP extension for the right version of PHP, etc.
autoconf and the m4 language that is used to configure it is arcane, and people have written alternatives, such as scons. I want to be able to use one of these when building a PHP extension.
In principle, you should be able to use scons or similar tools to build PHP extensions. However, I can't see how you would replace the phpize step.
Has anyone had any success in building PHP extensions with scons, or another more modern build tool?
The path of least resistance would be to have SCons run autoconf, phpize and whatever else is needed for your PHP extension. You may be able to extract the compiler configuration out of there and let SCons do the actual building, or you can simply have SCons run "make".
Declaring shell command targets from SCons is easy, but getting dependencies right is always tricky.
Basically you will have to let SCons know of any intermediate file produced by these external tools. This way it can not only properly clean them, but it can also cache the whole series of steps based on the content signature of each intermediate result (MD5 checksum).
Proper caching will significantly reduce the number of times these external tools will actually need to be invoked as the code base changes.
While I don't think somebody has written a specific solution for PHP, there are lots of custom builders on the SCons wiki that do similar things.
phpize(1) is just a shell script, so i guess you could modify it to work with scons...

Categories