7.1 Uninstalling extensions
NOTE: The brew installation actually creates configuration files in /usr/local/etc/php/5.5/conf.d, /usr/local/etc/php/5.6/conf.d, and /usr/local/etc/php/7.0/conf.d respectively. If you want to uninstall a PHP extension, simply rename the .ini file to .ini.bak and restart apache. Alternatively, you can simply use brew to uninstall it, and reinstall it again when you need it.
7.2 APC Cache
Caching in PHP is a big part of the performance equation. There are two types of caching typically available, and both have a big impact on speed and performance.
The first type of cache is called an opcode cache, and this is what takes your PHP script and compiles it for faster execution. This alone can typically result in a 3X speed increase!.
The second type of cache is a user cache, and this is a data-store that PHP can use to quickly store and retrieve data from. These typically run in memory which means they are transient, but very fast.
For PHP 5.5 and newer runs best with Zend OPcache by default but you can still use APCu Cache as a data store.
Install OPcache and APCu
Switch to the version of PHP you want to install for: PHP 5.6 by uncommenting the module in httpd.conf
then run the following brew commands:
brew install php56-opcache brew install php55-apcu
repeat the process for other versions of php:
Restart Apache with the standard
sudo apachectl -k restart
Point your browser to http://localhost/info.php and ensure you see a reference to Zend OPcache in the Zend Engine block.
Also scroll down and check you have an APCu section.
Note - if you have issues may have to reinstall with
brew reinstall --build-from-source php56-opcache
You actually have quite a few options when it comes to caching. There are also brews available for XCache, Memcache. To find an exhaustive list of all the available packages simply type:
brew search php56
7.3 YAML
To make use of the native PECL YAML library that allows YAML processing to be done by highly efficient libYAML C library rather than by the Symfony PHP library install the php55-yaml extension.
This can result in a 5X improvement in YAML processing times! Luckily this is a simple process to install for any PHP version:
brew install php56-yaml
7.4 Xdebug
One of the most important aspects of any kind of development is the ability to debug and fix your code. PHP comes with limited support to dump variables or log to a file, but for more complex situations you need something more powerful. Xdebug provide a debugging and profiling extension for PHP that provides an HTML-friendly output for the var_dump() method that improves the readability of the default version.
It also provides other useful dumping methods as well as displaying stack traces. One of the best features however, is the ability to remote debug your code. This means you can set breakpoints, and step through your PHP code inspecting as you go. Full documentation on Xdebug contains extensive information about all the functionality available.
Installation of Xdebug is just as easy as the previous installation of APC or YAML:
brew install php56-xdebug
Restart the server
sudo apachectl -k restart
You should also check the http://localhost/info.php to ensure that Xdebug information is displayed:
7.4.1 Xdebug enable/disable tool
W00fz created a great tool for quickly enabling/disabling xdebug. Install this with brew:
brew install xdebug-osx
7.4.2 Usage
Command | Usage |
---|---|
xdebug-toggle | outputs the current status |
xdebug-toggle on | enables xdebug |
xdebug-toggle off | disables xdebug |
xdebug-toggle on|off --no-server-restart | toggles xdebug without restarting apache or php-fpm |
7.5 Twig (C)
Used by Drupal 8 for faster compiling of twig templates
brew install php56-twig
7.6 Uploadprogress
Used by Drupal to render multiple file upload progress indicators
brew install php56-uploadprogress
7.7 Intl
Internationalization used by some Symfony apps (Akineo?)
brew install --build-from-source php56-intl