Better Workflow in PHP With Composer, Namespacing, and PHPUnit
videos

Better Workflow in PHP With Composer, Namespacing, and PHPUnit

Tutorial Details
  • Difficulty: Intermediate
  • Completion Time: 20 Minutes

In this video tutorial, we’ll again focus on workflow. Specifically, we’ll use Composer’s built-in autoloading capabilities, along with namespacing, to make for an elegant testing experience. We’ll also review a handful of PHPUnit best practices, as we get setup with these tools.


Additional Learning

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • jamjam

    What’s this obsession with PHP on nettuts recently?

    • jeff_way

      Nettuts+ has covered PHP quite a bit since the beginning. Nothing has changed.

      Our two core focuses are JavaScript and PHP. The remaining 25% goes to things like Rails, theory, etc.

      • http://laranz.in/ lawrence77

        Please post some interesting ASP.NET tuts too ;)

      • jeff_way

        We will, though that will always fall into the remaining 25% bucket. If we cover a different language/framework every day, we lose a big percentage of our readership. It’s important to have a key area of focus.

      • http://laranz.in/ lawrence77

        I agree, but in the remaining 25% i didn’t see a 1% for ASP.NET here :) Its also under Web Developement :) at least 1 nice post per month.

      • jeff_way

        True.

        Well, now, we’ve brought on Rey Bango as a regular contributor. So, he’ll surely be posting a lot more Microsoft content. Next week, we’ll be posting an article on making Visual Studio more web-dev friendly.

      • http://laranz.in/ lawrence77

        Great, looking forward.. Make sure its compatible with Visual Studio Express :)

        Thanks Jeff..

      • jamjam

        Jeffery. Wouldn’t you say there definitely been an increase in coverage of PHP over last few months? Maybe it’s just me as I moved away from the traditional lamp stack to all javascript/node stack.

      • jeff_way

        Not really. If I look on the main page, I see everything from PHP, to Rails, to Backbone, to architecture tutorials.

      • maurospage

        ^^^^^^^^^^^
        /agree

    • Quip

      What;s this obsession with attacking anyone posting PHP articles recently? How bout you writing your own kewl article on RoR/Python/Haskell/Scala/…?

    • rmwebs

      Well PHP has been going through some pretty great changes over the last 12 months. It makes sense for NetTuts to cover these latest changes. In comparison, Python, Ruby, etc have remained relativly unchanges, so all those articles that already exist on them here still apply.

      Plus PHP probably draws a bigger audience.

    • http://www.facebook.com/profile.php?id=100000605380087 Jeffrey Briceño

      What’s this obsession with PHP haters?

      • http://www.facebook.com/jesus.bejarano.948 Jesus Bejarano

        They are not called “haters”, more like “hipsters”.

  • Deniss

    I’m new to TDD, especially on PHP – I noticed that there’s is a handfull of tutorials in the “Testing PHP Session”, however the order seems confusing – could you guys recomend a place to start or maybe even some kind of progression? Great guide btw.. as always form Jeffrey.

  • jamjam

    Jeffery. What’s your opinion on Javascript for everything approach? Javascript on the client, Javascript on the server with Node, Javascript mobile phone applications using Sencha Touch for example, even Javascript to build desktop applications. This way you can concentrate in learning one language and pretty much do everything with it. I will love to see a tutorial/screencast that shows all things Javascript can do these days.

  • maurospage

    You article is always great, but in the last weeks your are talking mostly php only. I hope to see again some article about nodejs and other things.

  • ben

    This was a great tutorial. I been struggling to get my head wrapped around writing tests and this really helped out a lot. And thank you for having more advanced tutorials like this.

  • http://twitter.com/jontybehr Jonty Behr

    Nice and clear. Good job

  • http://www.facebook.com/jesus.bejarano.948 Jesus Bejarano

    Excellent lesson , i actualy downloaded the video.

  • http://brayanrastelli.com/ Brayan Rastelli

    Great post, thanks !

    Btw wich theme r u using on Sublime?

    bye

    • http://www.facebook.com/jesus.bejarano.948 Jesus Bejarano

      If my eyes don’t deceive me, i think that is one of Dayle Rees called “Yule”, use package control to install all his themes.

      • http://www.jeffrey-way.com Jeffrey Way
        Author

        It’s actually Dayle’s Mellow theme.

      • http://twitter.com/rodripcg Rodrigore Campos

        I think that is “Mellow” theme from Dayle Rees.

      • jeff_way

        Yep!

      • http://www.facebook.com/jesus.bejarano.948 Jesus Bejarano

        Yeah, “Yule” and “Mellow” look alike.

  • clubdesarrolladores

    Hi Jeffrey.

    Symfony2 works with composer and phpunit

    There is a posibility of cover Symfony2 with screencasts or tutorials like this?

    Thanks for your time.

    • jeff_way

      Sure. If we find the right person, I’d be happy to post Symfony tuts.

      • dardub

        Laravel 4 will be based on composer too. And I think you guys will be creating some tuts on that in the near future?

    • http://twitter.com/kesarito César Rodríguez

      it would be great! :-)

  • http://twitter.com/rollacoast Glenn Williams

    Another quality tutorial. Thanks.

  • Eduardo Matos

    Can you put your phpunit.xml in a gist?

  • http://twitter.com/rodripcg Rodrigore Campos

    That’s a lovely, lovely video

  • http://twitter.com/vladimir_light Vladimir L

    @jeff_way:disqus maybe a silly question, but what ST2 theme are you using? It looks like twilightm but its different. btw, love the “dark” selections!

    • jeff_way

      It’s the Mellow theme. Available through Package Control.

  • MPinteractiv

    Hey that’s php craze these days ! by the way i’m porting RIBBIT to SilexDoctrine ORM if you are interesed in it : you can see it running here : http://mpmedia.alwaysdata.net/ribbit and download sources here : https://github.com/Mparaiso/silex-ribbit , it should be working out of the box on any PHP 5.3 env , writing the unit tests right now , stay tuned.

  • Sitebase

    Nice one Jeffrey!

  • krike06

    Very useful, thank you jeff. I need to set this up for a few projects I have. I have never taken the time to use PHPunit, which is not really smart.

  • mkorsmo

    This was great.

    I would love to see a screencast/tutorial on using PHPUnit with CodeIgniter or Laravel. (Especially CI, but using it in the context of a Website/framework)

  • henyana

    Hi Jeffrey,
    Thanks for this useful tutorial

  • http://www.biztechconsultancy.co.uk/php-web-development.htm PHP Web Development

    This video tutorial is awesome and helps all the people whether it is beginners or experts to understood the workflow of php. Video is a best things to give practical knowledge.

  • karmicdice

    Hey Jeffrey,

    I must admit, this was ‘required’ to be on tuts+
    I had many people eating up on me for this and finally I have a tutorial to refer someone to.

    Just wanted to drop a thanks and ask 2 questions out of curiosity.

    What is ‘de facto’ framework for PHP? Or are these “Conventions” made to merge or single line “all” the frameworks? I am currently experimenting with Cake3-dev and CI3-dev… They are all on similar lines.
    Best part : No more PECL!
    Do you think PSR is the “prophesied” magic for organizing PHP?

  • rene

    I cant see the video

  • http://www.facebook.com/mmuruev Maksim Muruev

    Excellent tutorial, but you not mention how include abstract test classes with composer. I mean that composer just skip /test directory(I don’t wan’t hard code it in poduction composer.json). And phpunit not include those classes.