Joshua Estes


Using Phing and PHPUnit with Symfony2


So recently I have been playing a lot with phing, symfony2, and Jenkins. Today I will show you how to build a very basic build script that runs phpunit. Future articles I will show you how to add to your build script to generate documentation and eventually integrate it all into Jenkins.

First we need to update our composer.json file to include phing and phpunit if it is not already there.

"require-dev": {
    "phing/phing": "*",
    "phpunit/phpunit": "*"

Now we need to run the update command with composer to install the dependencies.

php composer.phar update phing/phing phpunit/phpunit

Awesome, now that we have both phing and phpunit, we can start on the build script.

NOTE: By default these are installed in vendor/bin however, if you have changed this, they might be installed elsewhere. Composer Docs

In your project root directory, create a build.xml and fill it with

<?xml version="1.0" encoding="UTF-8"?>
<project name="Acme" default="phpunit">
    <target name="phpunit">
        <exec executable="vendor/bin/phpunit" passthru="true" checkreturn="true">
            <arg value="-c" />
            <arg value="app" />

This will now run phpunit by default. Give it a try by running php vendor/bin/phing and it will run all your unit tests.

That’s all there is to it. In the next few articles I will show you some more in depth examples and configuring the Symfony2 test environment.


Friday May 24 2013 10:58:00pm


phing symfony2


Vagrant, Puppet, and Symfony2 - The Three Musketeers


So I have been playing with Vagrant, Puppet, and Symfony for about the past month or so. There have been a few issues that I have run into, but it has mostly been a joy to work with.


Vagrant allows you to use VirtualBox to spin up a virtual machine. This machine can be pretty much anything. The thing that makes vagrant so awesome is I can include the Vagrantfile in my repository and all a developer has to do is run vagrant up and if they do not already have the base box, it will download it for them and boot up the machine.

A box is basically a base server. For example, do a base install of ubuntu on a VM and that is where you will start from. It is where everyone else will start from as well. You will use Puppet to provision the box, but more on that later.

To get started, download vagrant. If you are using an old version of vagrant (ie 1.0.x) then you will need to uninstall it.

Here’s an example Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config| = "precise64"
  config.vm.box_url = "" :forwarded_port, guest: 80, host: 8080 :private_network, ip: ""
  config.vm.synced_folder ".", "/var/www/app.local", :nfs => true
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", "1024"]
  config.vm.provision :puppet do |puppet|
    puppet.options        = "--verbose --debug"
    puppet.manifests_path = "app/Resources/puppet/manifests"
    puppet.manifest_file  = "base.pp"
    puppet.module_path    = "app/Resources/puppet/modules"

I want to point out that the puppet.options can be commented out. I am one of those really odd people that like to see a lot of things scroll on the screen. This is also really helpful for when you run into issues when booting up the VM.

Another thing that I want to point out is the manifest and module path. These are both included in the app/Resources folder so there is one place within the project that I can put these. In my projects, everything in the modules directory is a git submodule.


Next, let’s work on the manifest file. You are going to need to include some modules. The ones that you will need are MySQL, Apache, firewall, and stdlib. Please read the documentation for these since they show you how to set use these in your manifest file.

If you would like to use more, you can visit for a large list of various modules.

Now let’s setup our manifest file.

exec { "apt-update":
    command => "/usr/bin/apt-get update",
# Dependencies
$dependencies = [
package { $dependencies:
    ensure  => present,
    require => Exec['apt-update'],
#### EOF: Dependencies ####

file { "/var/www/app.local":
    ensure  => "directory",
    #owner   => "www-data",
    #group   => "www-data",
    #mode    => "0775",
    recurse => true,

class { "apache": }
class { "apache::mod::php": }
apache::vhost { "app.local":
    priority   => 000,
    port       => 80,
    docroot    => "/var/www/app.local/web",
    ssl        => false,
    servername => "app.local",
    options    => ["FollowSymlinks MultiViews"],
    override   => ["All"],
    ensure     => present,
    require    => File['/var/www/app.local']

class { "mysql": }
class { "mysql::php": }
class {"mysql::server":
    config_hash => {
        "root_password" => "root"
mysql::db { 'symfony':
    user     => 'symfony',
    password => 'symfony',
    host     => 'localhost',
    grant    => ['all'],

I know there’s a lot of stuff in there, but once you take a look at it, it’s pretty straight forward. There might be some edits to this manifest file that you’ll need to make based on what you want to do.

As I was setting this up, one of the issues I had was trying to get packages installed via apt-get. The first part of the manifest takes care of that part.

Next, it will install all the php stuff. You can customize this to your needs. If you are working on a project and it complains that some feature needs to be installed, say mcrypt for php. Usually you would just run sudo apt-get install php5-mcrypt or apt-cache search mcrypt to find that package you want. This is all that puppet is doing. Pretty simple right?

So now I want to pick apart

file { "/var/www/app.local":
    ensure  => "directory",
    #owner   => "www-data",
    #group   => "www-data",
    #mode    => "0775",
    recurse => true,

I ran into some issues when I had the owner/group uncommented. This is because Vagrant sets up that directory as a NFS share. I left it in because I plan on eventually finding a way since when the project gets deployed, I can use puppet again. This also makes sure that this directory exists on the server.

Next comes all the apache stuff. It will setup your vhost and make sure that apache is installed and running. Update this to your liking.

NOTE: If you want to enable SSL, you need to be aware that you’ll need to setup the proper port forwarding. It took me a little while on Google to find some solutions.

NOTE: The vhost that is setup will response to requests that are for app.local so make sure you add a line in your /etc/hosts file. ie: app.local

Vagrant and Symfony

Now things should be ready for you to run vagrant up and watch the VM boot. If you did not comment out the puppet options in the Vagrantfile it can be pretty interesting to watch it work it’s magic.

There are a few things that you need to be aware of with this work flow. Most of the symfony console commands are now useless to you. Because MySQL is running on the VM you no longer can use run any commands that need to connect to the database.

You also cannot clear your cache or run some of the other commands you are use to. This is because the path on your host machine is different than the path on the guest machine. At least I assume this is the case.

To be able to run these commands, you need to ssh into the vagrant vm by running the vagrant ssh command.


I hope that you have learned something from this and in the future I will be posting about how I use Capifony to deploy this setup to a server.

Further Reading



Sunday March 24 2013 03:04:00am


vagrant symfony2 puppet


5 Causes of Failure


Failure to Protect Corporate Culture

Corporate culture is huge and not many people realize just how big of a deal this is. No matter the size of the company and even if you realize it or not, there is a culture within your company. Company culture can be defined as the meaning we give to our work. Our attitudes and actions that we do at work, and even the vision that the people at the top have for the company.

The main reason I see people failing to protect the culture is that managers are way too relaxed in hiring. Most of all the jobs that I have had in the past have been only one or two in person interviews. While this might be enough for some companies, I do not think it is enough.

All possible applications should start off with a basic phone interview. Ask some basic questions. You’ll find that within the first 15 minutes or so that the person on the other end is worth it or not. For me, this makes a lot more sense since a quick call takes a lot less time than someone coming in and showing them around the office.

If the applicant seems legit and seems to know what he/she is talking about, bring them in. Show them around, introduce them to other employees that they might be working with. See how they react, are they shy? Outgoing? Does it really matter? It depends on your culture. I feel that the next step is one of the most important. Have your experts vet the applicant. Get your experts to ask them questions related to the position they are applying for. If the person will be working with a graphic designer, not as one, get the senior graphic designer to sit done with them and ask them questions. Do they know anything about graphic design? Yes or no is a moot point. You want to see how well these two people bounce off each other.

So what happens when you do not protect your culture? You’re lagging indicator will be high turnover. People are leaving because the are not a good fit for the company. It could also be that people that might be a good fit for the company are leaving because of those who are not good for the company. Have you ever worked with someone negative?

Failure to Communicate

Communication is taking a message from a sender and having it delivered to a receiver. Doesn’t sound all that hard does it? BUT what happened in school when you played telephone? By the time the message got the the end it was so far from the original that it no longer made sense. This happens with almost everything we do at work.

When a new project starts up and no one is on the same page, that project may not fail, but will never be the best that the company can output. Sometimes this is called “managing expectations”.

There are a few different failures when it comes to this. The first is too many layers that the message has to travel. The regional manager tells the state manager, the state manager tells the district manager, the district manager tells the store manager, the store manager tells the employees. This, in my opinion, is way too complicated and has way too many layers to be effective.

The other type of communication failure happens when the sender cannot properly deliver the message. An example of this type would be if someone asked you to wash the windows, so you wash the inside of the windows. However, what the sender really meant to say was, wash the outside of the windows.

Failure to Change

As companies grow they need to evolve and when a company cannot evolve, it will fail. The company should always be asking, “Is this the best way?”, “What isn’t working about this process?”, and my favorite question, “What is the problem you are trying to solve?”. If a process is in place and it is apparent that it falls short of the goal you want, then keep what works and get rid of/change what is not working.

Far too often people will continue to do something while expecting better results. It also seems that a lot of people are in denial or at least too afraid to admit failure in a process they came up with. It’s also true that some people just keep on using the exact same processes that they were taught when they first came into the company.

Failure to Focus

An organization needs to focus on as few of goals as possible. It doesn’t make sense to focus on many different industries if you are a startup company. Do you think the bar code would have been as successful if it had been marketed to every industry and not just to grocery stores?

The case can also be made for a company that has a too specific goal in mind. For example, if my company only did blackberry apps. Why can’t I change the focus to mobile instead and blackberry apps be rolled up underneath that umbrella?

Failure to Acknowledge Experts

It is my belief that everyone is an expert in something. We can all learn something new from someone else. This is why I think of people as experts. If you are a graphic designer, you make things pretty and have specialized knowledge to do so. If you’re a [insert programming language here] developer, you make functional software and have the knowledge to do so.

The same is said for project managers, sales agents, etc. The point here is, look at everyone as an expert. Trust your experts! I’ve had the pleasure of having account executives tell me how to program. It’s very frustrating for someone to tell another how to do what they know the most about.

I know nothing of marketing, and therefore I would consult a CMO for these things.


These are the 5 things that I have found to be true while building my own companies and then having them crash and burn to the ground. I have also seem most of these in companies I have worked for in the past and have watched those companies slowly fail.

After spending a long time thinking about failure and reasons for failure, is where this list has came from. While most of these are reasons are related to a company, I think they have a lot to do with personal success and failures.

So I challenge you for entire week to, protect your culture: only allow those in your life that are like minded, communicate: make sure you can send your message to people and verify that they understand it, change: find something that is wrong in your life and find another way to do it, focus: stop multitasking and only work on one project at a time, and acknowledge experts: you’re not as smart as you think, learn from those around you instead of pushing your “knowledge” on them.


Tuesday January 29 2013 01:31:22pm
1 2 3 4
1 of 4
©2012–2014 Joshua Estes Twitter, Code, Videos, Ask me anything