News Robot

Vagrant in Zend Framework 1

I recently added support for vagrant to the Zend Framework codebase to enable easier testing. I was motivated by some work the joind.in folks have done to get a working development environment for joind.in development using Vagrant.

Vagrant is a fantastic tool that enables you to manage and run virtual machines from the command line, including automatic provisioning of them using puppet or chef. The really cool thing about it however from my point of view is that vagrant automatically sets up the VM with a folder called /vagrant that holds the code on your local hard drive from where you started the VM. This means that you can continue to edit your code in your local editor/IDE and test it within the VM easily.

I highly recommend checking it out.

ZF1′s Vagrant set up

The Vagrant set up for ZF1 is designed for testing ZF1 against multiple PHP versions. As such it sets up a simple Ubuntu VM with the required toolchain for compiling PHP and provides a script called php-build.sh which will download and build any PHP 5.2, 5.3 or 5.4 version that you are interested in. I based this script on information in Derick Rethans’ excellent Multiple PHP versions set-up article.

One thing that I discovered was that by default, the VM cannot create symlinks in /vagrant. The way to solve this is to add the following to the Vagrantfile:

  config.vm.customize [
    "setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"
  ]

I chose to use puppet to install the required packages and created a simple default.pp configuration. I’m sure this isn’t optimal, but it works :)

Running ZF1 unit tests

The process to set up ZF1 to run unit tests in a VM using PHPUnit 3.4, follow these steps:

1. Install requirements for running the VM:

2. Checkout the ZF1 repository:

    $ svn checkout http://framework.zend.com/svn/framework/standard/trunk zf1-dev
    $ cd zf1-dev

3. Start the process by running Vagrant.

    $ vagrant up

This will take a long while as it has to download a VM image and then provision it. Once it has finished, it will exit and leave you back at the command prompt.

4. SSH into the VM

    $ vagrant ssh

Vagrant sets up key-less ssh connections to the VM that “just works” :)

5. Build a version of PHP.

    $ php-build.sh 5.3.11

This also takes a while as it compiles PHP for you! It also installs PHPUnit 3.4 as that’s the version we need to unit test ZF1.

Each version of PHP that you compile is stored in /usr/local/php/{version number}. You can compile any version; I have 5.2.4, 5.2.12, 5.3.3 and 5.3.11 installed at the moment…

6. Select PHP to use:

   $ pe 5.3.11

pe is a handy shell function that Derick wrote that changes your PHP environment to whichever version your specify.

7. Run tests

   $ cd /vagrant/tests
   $ php runtests.php

Alternatively, you can run each component’s tests individually:

   $ phpunit --stderr -d memory_limit=-1 Zend/Acl/AclTest.php
   $ phpunit --stderr -d memory_limit=-1 Zend/Amf/AllTests.php
   (etc...)

Obviously, you repeat steps 5 through 7 for each version of PHP you want to test on.

Running unit tests on Zend Framework 1 is now considerably easier!

flattr this!

Author: Rob…

by News Robot on May 9, 2012 in News, No Comments »
tags: , ,

Potty Training Baby Powder

I would like to announce the immediate availability of Tobasco for Toddlers.  It is the diaper powder for stubborn children.  The way it works is that your child wears their diaper just as they normally would.  But prior to them putting it on you put a small amount of our special patented powder that is [...]
Author: Kevin Schroeder
Source: ESchrade

by News Robot on May 5, 2012 in News, No Comments »
tags: , , ,

ZendCon 2012 (or, how to get your talk accepted)

Well, planning for ZendCon has been underway for a while and we finally got our Call for Papers out the door!  We are following a similar process as we did last year.  We aren’t having specific tracks (which I am of the opinion are basically useless in a targeted conference like this), but we have [...]
Author: Kevin Schroeder
Source: ESchrade

by News Robot on May 3, 2012 in News, No Comments »
tags: , , ,

Remote Debugging with the Zend Debugger and PHPUnit

I’m trying to do some remote debugging with PHPUnit on a remote system.  I was following the rules I had written about in a previous article but for some reason I could not get path mapping to work.  So I figured I’d ping the Studio lead developer because as soon as I did that I’d get [...]
Author: Kevin Schroeder
Source: ESchrade

Why Modules?

I’ve blogged about
getting started with ZF2 modules
, as well as about
ZF2 modules you can already use
. But after fielding some questions recently,
I realized I should talk about why modules are important for the
ZF2 ecosystem.

Author: Matthew Weier O’Phinney

by News Robot on May 1, 2012 in News, No Comments »
tags: