PHP related information

No such file or directory for SSH authorized_keys in Homestead Vagrant VM

When configuring your Homestead VM you may encounter an SSH key issue when booting the Homestead Vagrant VM up
==> default: : No such file or directory
This can be fixed by nesting your mounted directory a level deeper under /home/vagrant/ as that is where the SSH keys of the box itself are stored and mounting your folders directory there can cause issues

Use Homebrew PHP with Mac OS X built-in Apache

To use the version of PHP you installed with Homebrew, you will need to change the PHP extension that Apache is loading. If you are using the built-in version of Apache this will use the built-in version of PHP even after you have installed PHP with brew. brew install php56 You need to edit the Apache config file /etc/apache2/httpd.conf and search for vimĀ /etc/apache2/httpd.conf Then...

Show SQL statement from CodeIgniter DB Query Builder

If you need to see (for whatever reason) the SQL being generated by CodeIgniter’s DB Query Builder, you can call last_query() on the helper
$sql = $this->db->last_query();
If you are using version 3 however, you should be able to use get_compiled_select() as mentioned in the CodeIgniter documentation

Icinga Web, Could not send command. Check if your webserver’s user has correct permissions for writing to the command pipe.

If you are getting this error when trying to perform actions on services or hosts in Icinga Web, most forum posts point to the configuration being correct, etc. Firstly make sure that the command pipe referenced in access.xml points to a valid place, and has icinga-cmd:icinga ownership vim /usr/local/icinga-web/app/modules/Api/config/access.xml <!-- allowed to be written to -->...

Icinga Web, Uncaught AgaviLoggingException thrown, Cannot open file “log/debug.log”

When trying to get Icinga Web to work, you may run into issue with the log directory not being writable Uncaught AgaviLoggingException thrown Cannot open file "log/debug-2014-01-28.log", please check permissions on file or directory. It doesn’t appear to be referencing the core directory, or any other relative directory, so the easiest fix is to create an absolute path to where...

Icinga Web, Set correct write permissions for directory “/usr/local/icinga-web/app/cache”

If you have followed the Icinga install procedure through as per the installation documentation, and are having difficulty getting Icinga Web to install, you may eventually get an Agavi error saying that the cache directory is not writable (if you find the PHP errors) AgaviCacheException Failed to write cache file "/usr/local/icinga-web/app/cache/config/config_handlers...

Add URL query parameters to links using view helper in Zend Framework 2

There are 2 ways to add query parameters using the URL view helper in Zend Framework 2, either using Segment route placeholders, or adding them as normal query parameters (e.g. url?id=1&name=barney) Which one you need to use depends on what route the view helper is being used on; since all URL’s in Zend Framework 2 need to be route-aware (even if you’re mimicking ZF1 routing) it...

Mock a JSON HTTP API response in a PHPUnit unit test for Zend Framework 2

In order to mock an API in a unit test, you need to be able to mock the response that comes back from the API request. Therefore you need to specify in the test what JSON (for example) would come back from the HTTP client. To do this in Zend Framework 2, you need to mock the Zend\Http\Client so that it always returns a mock response, and have the mock Zend\Http\Response always return the JSON...

Install ZeroMQ on Mac with PHP PECL extension

Getting ZeroMQ working on a Mac looks like a pain if you try to compile, but there’s a much easier way to get it up and running, with just a few brew and PECL commands. I’ve been wary of Homebrew for a while, as there were lots of issues with Macports in the past, but I’ve found it’s a lot easier than trying to compile various things yourself in OS X (I tried to compile...