Posts filed under “php”
Map invoke errors when using MongoDB MapReduce
When running MapReduce operations on your data, you must make sure that any fields you refer to within your map operation are available for every document in your collection. If you try a map operation and some documents do not have the required field, you will get the following assertion error when running the command: [...]
Getting started with MongoDB and PHP on Mac OS X
Introduction MongoDB is a document-orientated database written with scalability and high-performance in mind. It is one of a growing number of NoSQL systems – a database that does not rely on SQL or relational theory at all. Getting a MongoDB server working with PHP on Mac OS X is relatively straightforward, and this tutorial shows [...]
Install mcrypt PHP extension on Mac OS X Lion
If you have a need to install the mcrypt extension for PHP, for example if you need to use phpMyAdmin, then these instructions are for you. Thankfully, it is becoming simpler to install PHP extensions than with previous versions of OS X. Xcode The Xcode package installs the necessary versions of tools like autoconf which [...]
Mac OS X Lion PHP upgrade – php.ini and Suhosin
If you have upgraded from Snow Leopard to the new OS X Lion, you will notice PHP has also been upgraded – from 5.2 to 5.3. A couple of points that I noticed post-install. Firstly, my existing /etc/php.ini file was moved to /etc/php.ini-5.2-previous. Restoring this was trivial: sudo cp /etc/php.ini-5.2-previous /etc/php.ini However, I noticed that [...]
Install mcrypt PHP extension on OS X Snow Leopard
Please note: The following instructions apply to Mac OS X 10.6 (Snow Leopard). I have an updated guide for how to install mcrypt on 10.7 (Lion). mcrypt is a useful extension to PHP if you would like to support a wide range of encryption algorithms within your code. This guide explains how you can enable [...]
Normalize URL’s with PHP
I’ve posted to GitHub a PHP class that I’ve written which can handle URL normalization, as specified by RFC 3986. https://github.com/glenscott/url-normalizer Specifically, the following normalization steps are performed: Normalize case Decode unreserved characters Remove dot segments An example of use: require_once ‘URLNormalizer.php’; $url = ‘eXAMPLE://a/./b/../b/%63/%7bfoo%7d’; $un = new URLNormalizer(); $un->setUrl( $url ); echo $un->normalize(); // [...]
Install memcached PHP extension on OS X Snow Leopard
memcached is a very useful memory object caching system, which can be used to increase the performance of your dynamic scripts by caching database calls. This guide will explain how to install the memcached system, including the PHP extension, on Mac OS X 10.6. Xcode The Xcode package installs the necessary versions of tools like [...]
Fix PHP timezone warnings in OS X Snow Leopard
The standard Mac install of PHP has always been somewhat quirky, and 10.6 is no exception. One of the most obvious issues occurs when attempting to use date/time functions. PHP 5.3 requires that the date.timezone setting is available. Without this, you will receive a warning similar to the following: Warning: getdate() [function.getdate]: It is not [...]
PHP 5.3: The Good, the Bad and the Ugly
PHP 5.3 was released today; here are my positive and negatives: The Good: Closures Anonymous functions created with create_function have always been a bit messy. With 5.3 comes support for closures with a much cleaner syntax: $greet = function($name) { printf(“Hello %s\r\n”, $name); }; $greet(‘World’); $greet(‘PHP’); The Bad: Backwards incompatible changes Although not a massive [...]
mcrypt support for PHP on 64 bit Mac OS X 10.5
Please note: The article below refers to installing mcrypt on Mac OS X 10.5. If you have 10.6 Snow Leopard, please see my updated guide: Install mcrypt PHP extension on OS X Snow Leopard Adding additional functionality to the standard Apple-supplied PHP on Mac OS X 10.5 is a little tricky if you are running [...]