Thursday, November 17, 2005

Boost your Website with APC

Two weeks ago I plugged APC onto my main customers site, and I'm really satisfied by it now. I already tried it some time ago, but back then it had some problems with PEARs Quickforms and similiar heavy OO code, but those problems are fixed for about 90% now, some 8% can be easily fixed by reordering require statements and the like and finally the remaining ~2% are going to be fixed by Rasmus in the foreseeable future.

Note that I'm using APC with Debians PHP-4.3.10 and Apache2 package, which proofs a lot IMO ;) and there shouldn't be much that hinders you from trying it too!

Here's a very simple instruction to boost your PHP enabled webserver:

~$ pear download pecl/apc
~$ tar xzf APC-3.0.8.tgz
~$ rm -f package.xml
~$ cd APC-3.0.8
~/APC-3.0.8$ /usr/bin/phpize
~/APC-3.0.8$ ./configure --with-php-config=/usr/bin/php-config
--enable-apc --enable-apc-mmap
~/APC-3.0.8$ make all
~/APC-3.0.8$ sudo make install

APC is now installed somewhere in /usr/lib/php.

Some lines to add to php.ini:

apc.enabled = 1
apc.cache_by_default = 1
apc.shm_size = 32
apc.num_files_hint = 500
apc.mmap_file_mask = /tmp/apc.XXXXXX

If you want to cache only a certain virtual host, set apc.cache_by_default to 0 in php.ini and add the respective php_admin_value to your <VirtualHost> directive for the vhost.

The package also contains a useful status script, just copy the shipped apc.php to your document root. You'll see how the usage of the SHM segment grows by time, and after some time you'll also see what settings to use for apc.num_files_hint and apc.shm_size when the whole site is cached.

Sean recently added some APC docs, too!

Quod est demonstrandum, Website boosted! ;)

Wednesday, November 16, 2005

Time to say Good Bye

Yeah, it may come suddenly, but it's time to say good bye to curly braces used as string indexing operator.

PHP-5.1 will issue an E_STRICT error, and PHP-6 will probably don't know this syntax any more.

I don't know why, but I've got some strange sentimental feelings :-) , maybe because I've never used those other brackets for string indexing...

So, beloved, I already miss you! :'(

Submitting a bug for PHP

There will surely be the time where you find a bug in PHP, but prior submitting half hearted bug report make sure you've accomplished the following things:

If you're in doubt, read this if you didn't already (which you shouldn't tell anyone by the way).

Submitting a patch for PHP

If you once have that odd feeling that something in PHP is missing and you're brave enough to write something up (a patch) that would change that situation in your eyes, don't expect such a submission will make it into old branches.

Questions to include new features in PHP-4 or PHP-5.0 will most probably be declined (for a good reason), so the chance that the invested time is wasted time is rather high.

If you still feel confident about your addition, write the patch against the CVS HEAD or at least 5.1 branch, but for PHP-5.1 which is around the corner the probability for acceptance of new features has decreased a lot (or rather completely).

On the other hand, if your patch is trying to fix a bug, don't hesitate to provide a patch for every single CVS branch ;)

Sunday, November 13, 2005


...morons don't die off

PHP-5.1 around the corner

Here's a tidied up excerpt of the current NEWS file with all relevant changes since PHP 5.0, which may help on the decision to upgrade (even from PHP 4 :))


  • More than 350


  • Changed PDO constants to class constants (PDO::CONST_NAME)

  • Changed SQLite extension to be a shared module in Windows distribution

  • Changed "instanceof" and "catch" operators, is_a() and is_subclass_of() functions to not call __autoload()

  • Changed sha1_file() and md5_file() functions to use streams instead of low level IO

  • Changed abstract private methods to be not allowed anymore

  • Changed stream_filter_(ap|pre)pend() to return resource

  • Changed mysqli_exception and sqlite_exception to use RuntimeException as base if SPL extension is present

Extensions moved to PECL

  • cpdf

  • dio

  • fam

  • ingres_ii

  • mcve

  • mnogosearch

  • oracle

  • ovrimos

  • pfpro

  • w32api

  • yp

Upgraded PEAR

  • to channel-featuring v1.4

Upgraded bundled libraries

  • PCRE library to version 6.2

  • SQLite 3 library in ext/pdo_sqlite to 3.2.7

  • SQLite 2 library in ext/sqlite to 2.8.16

Upgraded bundled libraries in Windows distribution

  • zlib 1.2.3

  • curl 7.14.0

  • openssl 0.9.8

  • ming 0.3b

  • libpq (PostgreSQL) 8.0.1

Improvements and Additions

  • Improved SPL extension

    • Moved RecursiveArrayIterator from examples into extension

    • Moved RecursiveFilterIterator from examples into extension

    • Added SplObjectStorage

    • Made all SPL constants class constants

    • Renamed CachingRecursiveIterator to RecursiveCachingIterator to follow Recursive<*>Iterator naming scheme

  • Added support for class constants and static members for internal classes

  • Added PDO::MYSQL_ATTR_USE_BUFFERED_QUERY parameter for pdo_mysql

  • Added date_timezone_set() function to set the timezone that the date functions will use

  • Added pg_fetch_all_columns() function to fetch all values of a column from a result cursor

  • Added support for LOCK_EX flag for file_put_contents()

  • Implemented feature request #33452

  • Improved PHP extension loading mechanism with support for module dependencies and conflicts

  • Allowed return by reference from internal functions

  • Rewrote strtotime() with support for timezones and many new formats. Implements feature requests #21399, #26694, #28088, #29150, #29585 and #29595

  • Added bindto socket context option

  • Added offset parameter to the stream_copy_to_stream() function

  • Added offset & length parameters to substr_count() function

  • Removed php_check_syntax() function which never worked properly

  • Removed garbage manager in Zend Engine which results in more aggressive freeing of data

  • Improved interactive mode of PHP CLI

  • Improved performance of:

  • general execution/compilation

  • switch() statement

  • several array functions

  • virtual path handling by adding a realpath() cache

  • variable fetches

  • magic method invocations

  • Improved support for embedded server in mysqli

  • Improved mysqli extension

  • added constructor for mysqli_stmt and mysqli_result classes

  • added new function mysqli_get_charset()

  • added new function mysqli_set_charset()

  • added new class mysqli_driver

  • added new class mysqli_warning

  • added new class mysqli_execption

  • added new class mysqli_sql_exception

  • Improved SPL extension

  • added standard hierarchy of Exception classes

  • added interface Countable

  • added interfaces Subject and Observer

  • added spl_autoload*() functions

  • converted several 5.0 examples into c code

  • added class FileObject

  • added possibility to use a string with class_parents() and class_implements()

  • Added man pages for "phpize" and "php-config" scripts

  • Added support for .cc files in extensions

  • Added PHP_INT_MAX and PHP_INT_SIZE as predefined constants

  • Added user opcode API that allow overloading of opcode handlers

  • Added an optional remove old session parameter to session_regenerate_id()

  • Added array type hinting

  • Added the tidy_get_opt_doc() function to return documentation for configuration options in tidy

  • Added support for .cc files in extensions

  • Added imageconvolution() function which can be used to apply a custom 3x3 matrix convolution to an image

  • Added optional first parameter to XsltProcessor::registerPHPFunctions to only allow certain functions to be called from XSLT

  • Added the ability to override the autotools executables used by the buildconf script via the PHP_AUTOCONF and PHP_AUTOHEADER environmental variables

  • Added several new functions to support the PostgreSQL v3 protocol introduced in PostgreSQL 7.4

  • pg_transaction_status() - in-transaction status of a database connection

  • pg_query_params() - execution of parameterized queries

  • pg_prepare() - prepare named queries

  • pg_execute() - execution of named prepared queries

  • pg_send_query_params() - async equivalent of pg_query_params()

  • pg_send_prepare() - async equivalent of pg_prepare()

  • pg_send_execute() - async equivalent of pg_execute()

  • pg_result_error_field() - highly detailed error information, most importantly the SQLSTATE error code

  • pg_set_error_verbosity() - set verbosity of errors

  • Added optional fifth parameter "count" to preg_replace_callback() and preg_replace() to count the number of replacements made. FR #32275

  • Added optional third parameter "charlist" to str_word_count() which contains characters to be considered as word part. FR #31560

  • Added interface Serializeable

  • Added pg_field_type_oid() PostgreSQL function

  • Added zend_declare_property_...() and zend_update_property_...() API functions for bool, double and binary safe strings

  • Added possibility to access INI variables from within .ini file

  • Added variable $_SERVER['REQUEST_TIME'] containing request start time

  • Added optional float parameter to gettimeofday()

  • Added apache_reset_timeout() Apache1 function

  • Added sqlite_fetch_column_types() 3rd argument for arrays

  • Added optional offset parameter to stream_get_contents() and file_get_contents()

  • Added optional maxlen parameter to file_get_contents()

  • Added SAPI hook to get the current request time

  • Added new functions:

  • array_diff_key()

  • array_diff_ukey()

  • array_intersect_key()

  • array_intersect_ukey()

  • array_product()

  • DomDocumentFragment::appendXML()

  • fputcsv()

  • htmlspecialchars_decode()

  • inet_pton()

  • inet_ntop()

  • mysqli::client_info property

  • posix_access()

  • posix_mknod()

  • SimpleXMLElement::XPathNamespace()

  • stream_context_get_default()

  • stream_socket_enable_crypto()

  • stream_wrapper_unregister()

  • stream_wrapper_restore()

  • stream_filter_remove()

  • time_sleep_until()

  • Added DomDocument::$recover property for parsing not well-formed XML Documents

  • Added Cursor support for MySQL 5.0.x in mysqli

  • Added proxy support to ftp wrapper via http

  • Added MDTM support to ftp_url_stat

  • Added zlib stream filter support

  • Added bz2 stream filter support

  • Added max_redirects context option that specifies how many HTTP redirects to follow

  • Added support of parameter=>value arrays to xsl_xsltprocessor_set_parameter()

Saturday, November 12, 2005

Upgraded, finally

Yessir! I finally managed to upgrade s9y. It was quite a PITA because I had to go through all releases from 0.6 to 0.9, because it didn't work in one jump...

Could be that I'll be blogging more from now on.. (yeah, sounds like a threat, eh?)