XDebug, PHP and Sublime Text 2 on Ubuntu 12.04

Getting Xdebug for PHP working with Sublime Text 2 is slightly tricky.

Most of the instructions are at https://github.com/Kindari/SublimeXdebug - these notes are just a bit extra as a reminder to myself.

Read More

Running SauceLabs Selenium test suite locally with PHPUnit

SauceLabs provide a great hosted Selenium service for cross-browser testing in the cloud, which allows you to run a Selenium test suite against multiple browsers using the SauceLabs API and SauceConnect.

They also provide integration with PHPUnit, so that you can plug your SauceLabs Selenium tests directly into your PHPUnit test suite.

Sometimes, though, you want to run the same Selenium test suite against a single browser on your local machine, before you run the full thing against all the browsers on SauceLabs.

Read More

Upgrading PEAR if Guzzle install fails

I had a problem with the PEAR installer with the Guzzle package (a generally excellent PHP HTTP framework).

A channel discover would give the following error:

root@ip-10-56-47-23:~# pear channel-discover guzzlephp.org/pear
 Discovering channel guzzlephp.org/pear over http:// failed with message: channel-add: Cannot open "http://guzzlephp.org/pear/channel.xml" (File http://guzzlephp.org:80/pear/channel.xml not valid (received: HTTP/1.1 404 Not Found
 ))
 Trying to discover channel guzzlephp.org/pear over https:// instead
 Discovery of channel "guzzlephp.org/pear" failed (channel-add: Cannot open "https://guzzlephp.org/pear/channel.xml" (Connection to `guzzlephp.org:443' failed: Connection refused))

Strangely, I could fetch the channel.xml file manually and add the channel. But even then, the install would fail (with similar messages about 404 errors).

The solution seemed to be upgrading PEAR – I was running version 1.9.0 (check it with “pear -V”), so I upgraded it:

root@ip-10-56-47-23:~# pear upgrade pear

after which I had version 1.9.4. Then I tried the channel discover again, with much better results:

root@ip-10-56-47-23:~# pear channel-discover guzzlephp.org/pearAdding Channel "guzzlephp.org/pear" succeeded
 Discovery of channel "guzzlephp.org/pear" succeeded

 

PHP 5.3.0 and the “global” keyword

This had me stumped for a while – using some 3rd party code with PHP 5.3.0, the “global” keyword didn’t seem to work any more (references to the supposedly “global” variable from within functions always gave NULL)..

You have to declare the variable as “global” before setting it in the outer scope – then it works again.

So, this used to work (but doesn’t under PHP 5.3.0) :

$util = new Utility();
global $util;
function show() {
    global $util;
    echo "$util->version";
}
but if you swap the lines of the declaration of $utils, then it does work under PHP 5.3.0 :
global $util;
$util = new Utility();
function show() {
    global $util;
    echo "$util->version";
}