| /dev/null
Blog: PHP, Python, Linux, Web services & Continuous delivery

Tag: PHP

To generate a skeleton unit test when using a framework with autoloading you need to provide the bootstrap file or phpunit will not be able to find any parent classes.

phpunit-skelgen --bootstrap path/to/bootstrap/Bootstrap.php --test -- "namespace\qualified\Classname" Classname

The above assumes that you are running the command from within the directory that contains the class.

Read more

sublime text 2 dev setup

On upgrade to V2.0 I had issues with some of my favorite plugins so I’m starting again and writing down what I do this time. There are a few steps involved but it is worth the effort, you may have to occasionally restart the editor after installing a plugin in order for it to become available to use.

I#ve split the plugins I use into two categories: General and PHP specific

General plugins

> Package control

Install Package Control first, after that all plugins can be installed easily via the PackageControl interface, which you can get to from the main menu > Preferences > PackageControl.

Read more

I started writing a plug-in for SublimeText 2 to speed up the development of Zend Framework 2 (ZF2) applications called ZF2Helper. So far I've implemented a couple of features and I intend to add more as and when I come across a ZF2 task that would benefit from some automation. Below is a quick example of using ZF2Helper to create new ZF2 modules and new controller actions. The full source is available on github: https://github.com/pipe-devnull/ZF2Helper and the package can be installed in Sublime Text 2 using package_control.

Creating ZF2 Modules with ZF2Helper

Create an entirely new ZF2 module with 1 click rather than copying, pasting, renaming all files individually. Much quicker :)

This option is only available in the side bar context menu.

  1. In the side bar, navigate through to the root of the ZF2 modules directory
  2. Right click on the modules folder and select "ZF2Helper > New ZF2 Module"
  3. Input the name of the new module into the prompt
  4. Add the name of the module into the main ZF2 Application configuration file (ApplicationRoot / config / application.config.php)
Read more

Provisioning new Virtualbox LAMP development VMs from scratch can be dome with minimal effort using vagrant. By making this process easy and fast I can dedicate an entire VM environment for each development project I have on hand and be sure that my environment remains consistent. That last part is not new, we have been using VMs like this for years but in my experience the VMs often become too valuable because of the manual effort required for initial set up, provisioning software, and ongoing maintenance. Vagrant scripts enable me to build and destroy VMs several times a day at speed, as and when required - removing the manual overhead.

No more "it works on my machine" scenarios, keep development environments isolated and in line with production specifications.

Read more

I've just added support for xhprof profiler into my base vagrant LAMP (PHP) stack . It automatically adds profiling to any PHP file that is served from the default virtual host (document root: /vagrant/www/) and includes a link at the footer of each page over to the xhprof output. Graphviz has also been installed so callgraphs are generated if you want something more visual.

The vagrant instance is available on github here: https://github.com/pipe-devnull/vagrant-dev-lamp

Read more

This post accompanies a project I've put on Github that provides an example of how to use Behat & Mink to create automated browser based acceptance tests. By combining the concepts and tooling from Behavior Driven Development (BDD) with remote browser driver technologies, we will describe the desired behavior of a system and then transform these descriptions into test simulations running in real web browsers. The intention of both the demo project and the post is to highlight that:

  • Driving your acceptance testing process with BDD techniques is a valuable concept
  • Behat and Mink are a solid choice for implementing acceptance tests

The demo project consists of a web site that sells ascii art (The Ascii Art Marketplace) and a test suite that covers the features 'add to basket' and 'newsletter sign up'. It also contains a wrapper script that will run the tests in either phantomJS or Selenium, this can be useful when hooking things up with Continuous Integration (CI). For more info on using phantomJS with Mink & Behat see this section a bit further down.

In this post, I'm mainly providing some background and ramblings around BDD, why automating acceptance testing is so valuable and general information on Behat & Mink. If your already familiar with this stuff then you might want to skip straight to the github repo at https://github.com/pipe-devnull/mink-behat-acceptance-test-demo

Read more