PHP 5.4 – A Week In
It’s been a week since I switched over to PHP 5.4 and here’s what I can say, even though I haven’t had much time to use the new features I was looking forward to.
First of all, you won’t find PHP in your distribution repositories, it’s too early. Grab the source and compile.
My personal configuration line looks like this.
./configure \ --enable-fpm \ --with-openssl \ --with-pdo-mysql \ --enable-bcmath \ --with-pear \ --with-zlib \ --enable-mbstring \ --with-mysql-sock \ --with-curl \ --with-mysql \ --with-mysqli \ --enable-soap \ --with-gd \ --with-mcrypt \ --with-jpeg-dir \ --with-png-dir \ --enable-pcntl \ --enable-shmop \ --enable-sockets \ --enable-ftp
This has been trailing along for a couple of years now with only a couple of minor changes, probably something extra in there. Then
make test (yes, help PHP with 20-30 minutes of your time) and
make install (can be done during testing in background).
Skip to the part about PHP.
First thing I got upon launching PHP 5.4 was a fatal error.
Failed loading (...)xdebug.so: (...)xdebug.so: undefined symbol: output_globals
Okay, Zend version mismatch, no problem.
sudo pecl uninstall xdebug,
sudo pecl install xdebug…
...checking Check for supported PHP versions... configure: error: not supported. Need a PHP version < 5.4.0 (found 5.4.0)
Ouch... seriously? The solution was to grab the latest development version of Xdebug from github:
git clone git://github.com/derickr/xdebug.git
make test(why not?)
sudo make install
sudo vim (path/to/php.ini)set new path and enjoy
[Zend Modules] Xdebug
A very important Migration from PHP 5.3.x to PHP 5.4.x page is available. Couple of things worth noting from the very beginning:
- Safe mode, Magic quotes, Register globals - gone with the wind! Hurray!
- Sweet new functions hex2bin() - yes, I can finally throw away my
>>routines; I do work with binary a lot, so I'll be enjoying the new
0b001001101binary format as well.
- header_register_callback() - utmost useful for debugging,
cURL -vvdoes a great job, but now we can make sure we're the very last ones touching the headers
CURLOPT_MAX_SEND_SPEED_LARGEcURL options, can't wait to use
- json_encode - new options:
- The long-awaited
$limitparameter in debug_backtrace() allows for much more lightweight tracing of function and caller chains
- SessionHandler class, an object-oriented approach to sessions
- sqlite (v2) removed, ready to migrate your code to sqlite3?
<?=the open shorttag will now always be available
A week didn't really give much time to explore and try to use the new concepts in development. On most of the boxes I work on I'm lucky to get PHP 5.1.x, so nothing has driven me to use PHP 5.4 yet. I did play around with traits and of course the new built-in CLI webserver, which allows you to pull in PHP from any directory and server it over HTTP complete with simple routing.
Other than that, I can't say I'm either impressed nor unhappy yet due to the little time I've spent with its new features. I'll probably get some extra time to play around with a feature of particular interest in today's world of AJAX this weekend. 😉
Have you tried PHP 5.4 out already? What are your first impressions?