Process Forking with PHP

This article covers howto fork a child process using the PHP command line client and PHP process control functions. Several examples illustrate how to create child processes and make the parent wait until they have finished before continuing processing.

Categories PHP

Install APC for PHP on Linux

APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. What this means is that APC reads your PHP files, parses them into a more efficient binary format and then caches them in memory so that each request for your PHP files and PHP library files can be fed from the parsed cache. This will generally lead to a speed increase when serving a PHP site, especially one with a lot of library files. This post looks at how to install APC for PHP on Linux. The Linux distribution I used was CentOS 5, but it should be fairly similar for most distros.

Categories PHP

PHP echo with commas versus concatenation

"echo" and "print" are used in PHP for writing strings out to a stream. I have always used concatenation when writing out multiple strings with echo or print, but recently discovered that echo accepts multiple arguments or parameters, comma separated like a regular function call. This post does some benchmarking to see which is faster: echo with commas, echo with concatenation, or print with concatenation.

Categories PHP

Displaying PHP APC Cache Information

APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. I posted about how to install APC on Linux a couple of days ago, and will now look at the apc.php script which comes with APC and shows information about how much of the cache is being used, what files are being cached, the number of times they’ve been accessed etc.

Categories PHP

PHP Error Class ‘SoapClient’ not found

I’ve often found that something gets left out or forgotten when moving a website from an old server to a new install. I’ve just finished migrating one of my customer’s sites to a new CentOS 5.0 install with Apache 2.2 and PHP 5.1.6, and there’s one single PHP script in the site which uses the SoapClient class.

Naturally I’d forgotten to test this particular function until after the migration was complete, and was wondering why the script had failed. A quick look in the Apache error log file revealed the following error message: PHP Fatal error: "Class ‘SoapClient’ not found"

PHP Error Class ‘XsltProcessor’ not found

If you get the following error message in PHP then it means you need to have the XSL extension installed. Obviously the /path/to/file.php will be the actual path and filename of the PHP script the error occured in, and the line number will be the actual line. The PHP manual says that "PHP 5 includes the XSL extension by default" but one of my CentOS 5 installations it didn’t seem to be; the following post looks at how to install this extension on CentOS 5.

Fatal error: Class 'XsltProcessor' not found in /path/to/file.php on line 138
Categories PHP