Latest stories

Port forward http 80 and https 443 to 8080 or 8443 for Vagrant on Mac OS X

Assuming you have a Vagrantfile setup to forward port 8080 and/or 8443 to the default http and https ports on the web server running in the Vagrant Virtual Machine guest, you can forward these ports to the normally reserved ports on your Mac OS X host Create a port forwarding rule for both http and https ports that forwards 80 to 8080 and 443 to 8443 on your Mac (thanks to Abe Tobing for his...

MySQL Workbench client with Vagrant MySQL on Virtual Machine

If you prefer to use a client for MySQL such as Workbench, you can connect to the MySQL service in your Vagrant Virtual Machine by using SSH tunnelling. Run “vagrant ssh-config” to get the information you need to configure your client correctly. vagrant ssh-config Host default HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no...

Upload Behat screenshot to Imgur on scenario step failure

Being able to save a screenshot from Behat via one of it’s drivers is very useful to find out what went wrong, especially on headless browsers such as PhantomJS. Previously I’ve saved these to the filesystem as per a handy UCSF guide and updated myself for Behat 3. However if you do not have easy access to the filesystem where Behat is being run, such as your Continuous Integration...

Save a screenshot in Behat 3 on a failed scenario step

If you are using Behat with Selenium server and running locally, if is firing up real browser instances via web driver then it is easy to see what may be going wrong. However if you are using a headless browser such as PhantomJS this makes it impossible, unless you take screenshots when an error has occured (a failed step in your scenario) I used a handy UCSF guide for taking screenshots with...

Fix SSL certificate problem using Behat, Guzzle and Goutte on localhost

If you have an application that you are trying to test locally (such as on a Vagrant VM) or on a development server that has a self-signed certificate, Behat will probably complain of an SSL certificate problem because of an invalid certificate chain (GuzzleHttp\Exception\RequestException) This is because Guzzle (the http client used by Goutte, the default Mink driver) believes the connection to...

Javascript redirects double-encoding GET query parameter such as arrays [] %255B %255D

If you are passing query parameters such as arrays, Apache may double-encode them so that %5B and %5D becomes %255B and %255D for URLs that are submitted such as: ?a[b]=1&a[c]=2&d[]=3&d[]=4&d[2][e]=5 If you are making Ajax or API calls from a Javascript library (such as via jQuery or Angular) then it will encode the URI initially, then the web server (such as Apache) will 301 or...

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 libphp5.so vim /etc/apache2/httpd.conf Then...

Use CORS for REST API via XDomain proxy in IE8, IE9 for JavaScript/Angular

Because Internet Explorer 8 and 9 don’t support CORS properly (no custom headers such as an API key, only GET/POST, etc.) you may have problems using a modern REST API. However Jaime Pillora came up with a great solution called XDomain which acts as a pure JavaScript proxy for your API calls to get around CORS. This will only work if you have control over both the API you’re consuming...

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