Grunt.js + Symfony2 Big Brother Watches Your PHPSpec Descriptions

Straight to the point!

Drop a couple of files into your Symfony2’s project directory or any php library:


module.exports = function (grunt) {
        shell: {
            tests: {
                command: [
                    'vendor/bin/phpspec run -n --ansi'
                options: {
                    stdout: true
        watch: {
            tests: {
                files: ['{lib,src,spec}/**/*.php'],
                tasks: ['shell:tests']
    // plugins
    // tasks
    grunt.registerTask('tests', ['shell:tests', 'watch:tests']);



    "devDependencies": {
        "grunt": "~0.4.1",
        "grunt-contrib-watch": "~0.5.1",
        "grunt-shell": "~0.3.1",
        "grunt-cli": "~0.1.9"

Then proceed to install the dependencies above similar to composer like a pro:

brew install node
npm install

Then for your commodity create a file like:

~ cat ./dev
node_modules/.bin/grunt tests

and simply run:


And try to change a file in your folders src, lib or spec and you will see the watcher in action.

Now start doing PRs to your favourite repos with these changes and give the reference url if you want :)!

I credit @chadrien for helping me get up to speed with this technique.

You are welcome to say thanks buying The Lean Book on Symfony2 Ecommerce !

With the support I will buy a license of keynote to present my talk in Argentina in this conference:

undeservingly thankful, your friend


One thought on “Grunt.js + Symfony2 Big Brother Watches Your PHPSpec Descriptions

Leave a Reply

Your email address will not be published. Required fields are marked *