PHP Has No Culture of Testing

Sebastian Bergmann » 10 May 2008 » in PHP » 8 Comments

Charles Nutter, a Sun engineer who has worked on the JRuby project, commented on PHP in a panel discussion at Sun's CommunityOne conference.

I will not join the "PHP vs. Ruby on Rails" "discussion" here, as the comparison of a programming language to a web application framework for another language does not make sense, IMHO. Instead, I would like to comment on two of Charles Nutter's points.

"With PHP, everyone has his or her own way of doing applications."

I think it is a good thing that the PHP community has a rich offering of framework solutions to choose from.

Although it looks like everyone and their mother is standardizing their PHP-based web application development using the Zend Framework, other component libraries such as the eZ Components and web application frameworks inspired by Ruby on Rails such as Symfony or CakePHP are thriving.

"Testing and tried-and-true design patterns are not part of PHP culture."

Yes, testing has become mainstream / popular thanks to JUnit and the Java community.

Yes, the fact that Ruby on Rails encourages test-driven development is a good thing.

Maybe it took the PHP community a little longer to realize the importance of testing. But now that we know how to build applications that "just work", are fast and scalable, as well as secure, a big topic in the PHP community right now is to implement processes and use techniques that help us assure that the software works correctly throughout the its lifecycle.

As for design patterns: Too many PHP developers are blindly using the GoF Design Patterns in PHP, even when they are not applicable. We have our own design patterns and idioms, though. Things that have no name help developers every day to write scalable code that just works.

Defined tags for this entry: , , ,

Trackback specific URI for this entry

8 Comments to "PHP Has No Culture of Testing"

Display comments as (Linear | Threaded)
  1. Toby
    10/05/2008 at 10:43 Permalink
    Very good article, Sebastian, I fully agree with your points.

    Reply

  2. Pádraic Brady
    10/05/2008 at 12:52 Permalink
    I'm still pretty sure testing remains very low key in PHP and will for a while longer. While it's true testing has made enormous ground PHPers still seem to sit behind the curve of other languages when it comes to applying testing patterns and various testing practices.

    Reply

  3. Joshua May
    10/05/2008 at 14:21 Permalink
    See, I've found _quality_ to what's lacking in many PHP apps, unit testing being a significant part of that.

    See, unit testing often means you have to have a way of mocking interfaces, which often leads to cleaner, more separated (and often consequently, more extensible) code.

    I mean, that's just a simple example. But it's a big reason that PHP is so heavily frowned upon by larger companies here in Australia - "it's just not professional". And, to a large extent, I agree. But that's for another day.

    Reply

  4. Sebastian Bergmann
    10/05/2008 at 15:07 Permalink
    Yes, part of PHP's "bad reputation" can be attributed to the bad quality of both off-the-shelf applications and reusable components.

    It is getting better, though. The eZ Components and Zend Framework are just two examples of projects that consequently use unit tests to assure the quality and improve the design of their code.

    Reply

  5. Evert
    11/05/2008 at 00:19 Permalink
    Even though unit tests is becoming more popular in public frameworks, I see it pretty much no where used in practice.. Just rarely I'm pleasantly surprised finding some tests in somebodies code..

    I completely agree with "With PHP, everyone has his or her own way of doing applications.".

    And, that sucks as a library-writer too, because it makes it difficult to expect certain components to exist. Like, if I knew Zend would always be around, I can depend on its caching classes; However, this is rarely the case so I end up writing all code completely independent from any PHP library, and only depend on certain PHP (c-)modules to be around.

    Reply

  6. Ariz Jacinto
    11/05/2008 at 19:51 Permalink
    That's is where the opportunity knocks in. i've worked and working on PHP projects that requires TDD using Unit/Fit testing. PHP usage is maturing, so we'll obviously get there.

    Reply

  7. Gaylord Aulke
    14/05/2008 at 18:15 Permalink
    "Too many PHP developers are blindly using the GoF Design Patterns in PHP, even when they are not applicable. "

    Thanks for this statement, Sebastian.

    BTW: In our current Project (all PHP) we have over 400 Tests (Selenium and Unit) and code coverage (lines) > 75%

    Test Culture is here!

    Reply

  8. Jon Lebensold
    20/05/2008 at 10:16 Permalink
    Personally, I want to write my apps using a test driven approach but the tools in PHP just aren't as mature as their Java / Micrososft counterparts!

    Zend Studio still seems buggy and not worth the price tag (at least from what I read on their mailing list) and PDT seems to be the only alternative.

    The GoF patterns are a great reference but are by no means the be all, however I think that the PHP community needs more experience with patterns. The ones that come to mind stem from PoEAA (Fowler). Especially when MVC is being debated by architects in the Java / C# world, I think the PHP community's slow adoption of patterns has saved them from design and architecture issues that come from someone dictating MVC (or similar catch-all patterns) as a "best practice" for any and every application.

    Good summary

    Reply

0 Trackbacks to "PHP Has No Culture of Testing"

  1. No Trackbacks

Add Comment


To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Submitted comments will be subject to moderation before being displayed.