Why 2013 is the Year of PHP

Why 2013 is the Year of PHP

2012 was an excellent year for the PHP community, thanks to many badly needed features being added to version 5.4, as well as the countless projects, advancing PHP to the next level.

In this article, I’d like to review a handful of the issues that people had with PHP in the past, and provide a glimpse at why 2013 just may be the year of PHP!


Why the Hostility?

This may come as a surprise to you, but many people have negative feelings toward PHP developers, and the language as a whole. You likely know exactly what I mean, if you’ve considered learning Ruby in the past couple of years, due to some sense of peer pressure.

However, before you make any changes, you have to ask yourself: “Why does PHP have such a stigma?”

Well, like many of life’s important questions, there is no clear-cut answer. After doing a bit of searching online, for some PHP arguments, you’ll find that roughly eighty percent of the arguments against PHP are rooted in ignorance, in one form or another.

Roughly eighty percent of the arguments against PHP are rooted in ignorance.

The Beginners

There are the beginners, who don’t really know how PHP works. This results in questions, like “Why can’t you listen for button events with PHP?,” and similar questions about AJAX.

One Language to Rule Them All

Next, you have the folks who don’t know about other language or framework than the one that they currently use. These are the types of people who make arguments, such as “Rails is much easier then PHP,” and things like that.

Fighting PHP 4

The third form of misconception comes from the people who haven’t kept up with PHP’s advances over the years. Instead, they’re still fighting the language, as it existed years and years ago. This results in statements, like: “PHP isn’t object oriented” or “PHP sucks because it doesn’t support namespacing.” You get the idea.

Scaling

Lastly, we have the more intelligent developers who believe that “PHP can’t scale” or “PHP has no standards,” which is completely false. Scaling has less to do with the language, and more with the server and how your app is structured. As for standards? Well, it only takes a quick Google search for PHP-FIG.

What is the PHP-FIG? “The idea behind the group is for project representatives to talk about the commonalities between our projects and find ways we can work together. Our main audience is each other, but we’re very aware that the rest of the PHP community is watching. If other folks want to adopt what we’re doing they are welcome to do so, but that is not the aim.”

It’s an unfortunate truth that some arguments, which permeate through the web are either completely false, or updated.


PHP Isn’t Perfect

There’s truth in every criticism, however.

There’s truth in every criticism, however. PHP isn’t perfect. When it comes to its implementation of core features and functions, PHP is inconsistent. These arguments are entirely valid.

These inconsistencies are not without reason, though. PHP started out as what we would refer to today as a templating language. Since then, it has gone through multiple paradigm shifts, transforming into a functional language, like C, and then to the fully OOP language that we enjoy today. Along the way, best practices have emerged, and different people have been in control of what is added. This results in a lot of “different” kinds of code in one language. Now you might ask, “Why not just deprecate the bad parts?

The answer to this question is the same as to why we are still building sites for old versions of Internet Explorer. Don’t get me wrong; I would love to just drop it, but massive changes like this can’t be done without a bit of time. Hopefully, over time, PHP will advance further into OOP, and begin converting its objects to use their functions with the dot notation, rather than the admittedly awkward -> syntax. So, instead of array_push($arr, "Value");, you would write something, like $arr.push("Value");.

Don’t worry; things like this have been happening slowly. Just look at the new PHP 5.5 features. The old function-oriented MySQL add-on has been deprecated, in favor of the newer object-oriented approach.


The Present

Now with the past covered, let’s move up to the present. There are a handful of really cool projects and movements, some of which borrow ideas from other languages, in order to propel PHP to the next level.

Let’s consider the following:


Composer

The PHP community can now stop reinventing the wheel over and over again, thanks to Composer.

Inspired by tools, like Bundler and NPM, the PHP community can now stop reinventing the wheel over and over again, thanks to Composer. Node.js was the first language that made me feel comfortable with using packages. If you’ve used it before, then you know what I mean. Packages are installed locally to your project’s directory, it’s easy to find documentation for most of the plugins, and it’s relatively simple to submit your own packages.

PEAR?

PHP did offer an alternative for years, PEAR, but it wasn’t overly intuitive or easy to use. It felt bulky for something that ultimately fetched plain-text files. Further, it installed all packages globally. This forced you to inform people which packages you used when distributing your source code. As you might guess, this resulted in mis-matched versions, and other things of that nature.

If you so desire, you can pick and choose your components.

Composer fixes all of this, thanks to locally stored packages, and the ability to create per-project dependency files. This means you can easily distribute your project with this dependency file, and others can use their own copy of Composer to automatically download all specified dependencies, while simultaneously keeping them up to date.

Additionally, Composer is a light application – written in PHP, itself – and comes with an autoloader feature. This works off of the PSR-0 standard (mentioned above), which will automatically load your dependancies as you need them, so your application remains as clean as possible.

All of these features are a definite improvement, however, without community adoption, it means nothing. I’m happy to inform you that it’s been very well accepted. Big projects, such as Symfony and Laravel, have already uploaded their components to the Composer library, Packagist. Having the framework split up into components means that you can easily build your own custom framework to match your liking. In other words, no more bloated frameworks. If you so desire, you can pick and choose your components.

Need an example? You could take the database component from Laravel, and pair it with the templating component from the Symfony framework. In fact, the Laravel framework, itself, leverages many well-tested Symfony components. Why rebuild the wheel, when you can instead focus your efforts on other areas?


Laravel

Even if you do have issues with some of PHP’s inconsistencies, Laravel abstracts nearly all of it.

Now this wouldn’t be an article about PHP’s future without discussing Laravel in a bit more detail. We’re often asked why Nettuts+ seems to be pushing Laravel as much as it has been. This is the wrong question. Instead, ask “Why not?

Even if you do have issues with some of PHP’s inconsistencies, Laravel abstracts nearly all of it, providing you with the feel and elegance of a language, like Ruby, but with the ease of PHP.

Laravel comes with Eloquent, an ORM that completely rethinks everything to do with databases. I mostly use MySQL with PHP; what you get back from the database is a resource object, which you then have to run through a function to capture the results. In Laravel, everything is returned as standard PHP; you’re given objects, which you can modify and save. You can do things, such as combining results from multiple tables to save on database calls (referred to as eager loading), and laughably simple to do things, like validation and custom queries. As a bonus, if you don’t like SQL, well all of this can be done with an OOP style, using simple and readable methods, such as find and delete.

We’ve only seen the tip of the iceberg with what Eloquent brings to the table, but, already, you can see the improvements. Laravel brings this kind of innovation to nearly every field of PHP, including things like templating, routing, migrations, RESTful classes, and more. The best part, though, is that, with each new release, Laravel’s creator, Taylor Otwell, continues to raise the bar.

If you’d like to learn more about Laravel, I recommend the Tuts+ Premium course, Laravel Essentials, taught by our very own Jeffrey Way. I’m not saying this as a part of the Nettuts+ staff, but as a person who watched the series. I can honestly say that I had zero knowledge of Laravel going in, and Jeffrey did an excellent job of covering as much as possible.

Ultimately it’s not really about the framework, but the community support. As long as there is support for a project, it will be updated and will remain relevant. If your worried about how long it will remain popular, then, simply by actively using it, you are securing your odds!


PHP 5.4 / 5.5

The next thing that I’d like to discuss is the updates to PHP that were released in 2012. With the release of version 5.4 came a plethora of excellent new features. For a full overview of the updates, you can take a look at these two articles here on Nettuts+: 5.4 article, 5.5 article.

But, for a quick recap of my favorites:

Traits

  • Traits add the ability to create Class “partials,” which allows you to create consistent objects without re-writing everything over and over.

Generators

  • Generators let you do some cool things with lists of data, as well as allow you to benefit from all the features that come with lazy-evaluation.

CLI Web Server

  • Another great addition is the built in web server, which allows you to test your applications with different versions of PHP, without the need for something like Apache.

Dereferencing

  • Dereferencing is not a major addition, but it’s nice to be able to reference child elements without the use of functions. This includes things like accessing individual characters of a constant by using only square bracket notation.

The New Password Hashing API

  • With the new API, you are given the ability to both encrypt strings, as well as verify and strengthen passwords – all without any knowledge of bcrypt or any other hashing algorithm.

These represent just a few of the new improvements, and their is a whole list of things that are currently being discussed for the next version, scheduled to be released later this year.


Test Driven Development

Finally, let’s talk a bit about testing your code. While admittedly a bit late to the game, in 2012, our community saw widespread adoption of the test driven development methodology. I could make up a growth percentage, but I feel that a better indication of truth is to simply looking around on different dev sites and forums. You’ll surely see a spike! When it comes to testing in PHP, PHPUnit is the well-accepted standard.

Why is it Important?

Think about your project before diving in, like a cowboy.

Many times, you set out to write some code, but you lose something in the translation. What I mean by this is that you plan on one thing, but when implementing it, you lose a bit of the integrity or functionality. Another common problem arises when writing code for large projects: you end up with multiple classes and files that each have their own dependancies. What your left with is an “intertwined evolution” of functionality that can prove difficult to keep track of and maintain. Like a game of Jenga, by updating one piece, you may break another, crippling your application. These are just two example problems, but there are certainly others.

How Does TDD Help?

Well, you write clear tests before writing any production code. This means, when you get to writing your actual code, it is forced to conform to your original plan. Not only this, but, down the line all, dependencies will be tracked in your tests. If you update a bit of code, and inadvertently break one of the tests, you will immediately be notified.

Yes setting up these tests requires an extra step, but so is thinking before you speak. Does anyone the benefits of that? Of course not. The same is true for tests: think about your project before diving in, like a cowboy.

Additional Learning

Conclusion

It’s an exciting time to be a PHP developer. Many of the inherent problems have or are being fixed. AS for the other issues, we’ll those are easily remedied with a good framework and testing.

So what do you think? Are you getting on board? Disagree with me? If so, let’s continue the discussion below!

Tags: editorial
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://nikkobautista.com Nikko Bautista

    Great article Gabriel!

  • stephen_orr

    I work as a PHP developer, which means I’m reliant on PHP for my income. But that doesn’t mean I have to like it.

    PHP lately is heading in the direction of being Java-like. Massively over-engineered frameworks like Symfony2 are a big part of the reason, especially in conjunction with the Hibernate-inspired Doctrine2.

    I object to these on three main grounds:

    1) It used to be easy to get into PHP – it still is – but these frameworks make it SO much harder to build a simple website in. I’ve briefly checked out Laravel, but haven’t tried to build anything complex.

    2) These frameworks turn one of the advantages of PHP – performance – into a major negative. When you absolutely _have_ to implement HTTP caching to get reasonable performance out of your framework, then you know it’s too heavyweight. And often, by the time you realise this, it’s too difficult to strip back to basics and you’re stuck with it.

    3) If I wanted to write Java-style code, I’d have learned Java. I’m a PHP developer, and I prefer to write simple, logically structured code without having to handle dependency injection and the like.

    I’ve been working with Ruby for my personal projects for a few years now, and I’m much happier with the experience so far – it’s still simple to put together a basic app, and although performance does become a concern, it’s no slower than PHP. Maybe that will change; maybe I’ll move onto Node, or Objective-C, or Clojure, or Scala… you get the picture, there’s enough alternative options out there.

    In short, I’m very dubious about declaring 2013 to be the Year of PHP. I think we should declare that 2013 should be the Year of Using the Right Language for the Right Job. That, I can get behind.

    • jeff_way

      I think most folks would agree with using the right language for the right job. By “Year of 2013,” we mean that it’s the year when PHP pushes forward in a big way.

      • firefox

        hey Jeffrey, can’t you start a campaign to a PHP fork that breaks BC but evolves to a better OO language? with proper needle haystack order to burn the haters? :) :) :)

      • Will

        Why? Just use ruby. No I’m not being glib, what would be the point? You wouldn’t have the ease of deployment, wordpress or silverstripe. Without those things, ruby would be a much better choice for all web jobs. And the inverse of that is ruby would be much better for all web jobs if it had a really good choice of CMS, eComs & was easier to deploy.

      • stephen_orr

        Trouble is, Ruby is pretty easy to deploy these days. The days of arcane syntax being required faded away with the appearance of Heroku and EngineYard, but even if you’re doing it yourself it’s not too bad.

        I agree that not having a major player in the CMS field is holding Ruby back; although for the record I rate WordPress MUCH higher than I do SilverStripe (and I’ve worked extensively with both).

        As for eCommerce platforms, the core of Shopify is open-source…

      • asecondwill

        Yeah, agreed its getting better. Especially for big projects. Not so much for smaller stuff like client CMS sites that might be on shared hosting. I’m in Australia, so its all a bit backward. No local Linode here.

        Shopify is open-source? I didn’t know that, thanks! Also Spree, also – refinery cms. But yeah wordpress is so quick & easy & has so much community its hard to compete with. Silverstripe’s power & structure is also very impressive.

        Even so, I switched over to ruby for many of my web projects after years and years in PHP and it is miles better. Obviously Rails is hard to beat, we do smaller one off sites with Sinatra and power static site / prototyping with Middleman. Its just a better environment.

      • stephen_orr

        Shopify itself isn’t open source, but large chunks of the code have been open-sourced as the Active Merchant library. I’ve seen a number of ecommerce solutions based on that over the last couple of years. I know that Spreedly use parts of Active Merchant for their payment processing service, for example.

      • stephen_orr

        I’m still not convinced it needs to push forwards in a big way, and based on some of the arguments I’ve seen on the PHP internals list, I kind of think that what PHP needs is a unified direction; there’s enough in-fighting to distract from allowing PHP to become the best possible language it can be.

    • Quip

      Nobody persuades you to use Symfony which you hate for being java-like. You still can write anything you want with pure PHP, or go with Silex.
      Talking about performance – try PhalconPHP, and I’m serious about it.

      • stephen_orr

        I hadn’t heard of PhalconPHP – I’ll take a look.

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

        Is a framewok wrtten as a extension of C , it acclaims to be the mos fastest “php” framework ever, comes from the legendary, exotic and forgotten land called Latinoamerica :).

    • HairyHoleBeardy

      You’re talking like they bloated PHP’s core with some Java libraries and changed everything. Symfony2 and Zend are heavyweights and can feel like Java but what you’re missing is that you don’t have to use them, and at the same time you can make your life easier with well tested components, you can even make your own framework/abstraction layer on top of each component of them. If you still don’t like that, just ignore it and choose between the millions of libraries that Composer can autoload and manage dependencies for you in a few seconds.

    • http://gabrielmanricks.com/ Gabriel
      Author

      I have to agree that something like symfony is not meant for every project. The learning curve is pretty steep if you are only working of the documentation, and it’s not very light weight.

      I usually stick with micro frameworks like slim, they are pretty easy to get started with, and they are very unobtrusive.

      Unless you’re building a large app that you can really benefit from the rigidness to keep everything clean, I would recommend for you to use Slim.

      • stephen_orr

        The rigidity of Symfony2 is partly what’s caused me issues :) I’ll have a look at Slim.

  • http://www.facebook.com/gustavo.andradeferreira Gustavo Andrade Ferreira

    PHP FTW

  • http://www.facebook.com/jarrett.croll Jarrett Croll

    Doctrine 2′s ORM is a data mapper which is much more powerful than an Activerecord implementation. I looked at Laravel’s Eloquent and it does not appear to be a data mapper to me. You guys can push Laravel over Symfony2 and Zend 2 if you like but I think best to be recommending Doctrine if you want to encourage people to “do it right”. Perhaps an article on how to get Doctrine 2 up an running in a Laravel install is called for.

    • jeff_way

      Laravel leverages a number of Symfony components. So, by pushing Laravel, we’re also sort of pushing the Symfony codebase.

    • MPinteractiv

      and you can use doctrine with Laravel too…

    • stephen_orr

      That said, for all of Doctrine 2′s power, it seems to be a bit of a nightmare when you get complex domain models (although, that *could* be something that we’re doing wrong with it).

  • http://www.facebook.com/jarrett.croll Jarrett Croll

    @stephen_orr classic rubyist mentality. These additions to PHP are exactly what’s bringing it on par with RoR for building reliable, extensible, well engineered web applications. If you are comfortable building your smallish apps in RoR then please take your own advice and continue to do so!

    • stephen_orr

      Thanks Jarrett, it took me a while to find your post because you hadn’t replied directly to mine :) I appreciate your comments. One of the most impressive things I’ve found about all of the comments here is that none of them are attacking me for daring to criticise PHP; this is a level of maturity that’s been lacking in previous years.

  • http://www.facebook.com/carlosleopoldo Carlos Leopoldo Magaña Zavala

    Great article, but Laravel?… I don’t know, I think this framework is so amateur compared to what we we have: much better architectures available such as Zend Framework 2 and Symfony 2.

    • Peter

      I’ve always found Zend and Symfony to be over-engineered. CRUD apps are simple, and your framework should reflect it. Laravel is a winner.

    • jeff_way

      Again – to use Laravel is to leverage many components from Symfony. That’s the idea behind Composer. Taylor doesn’t have to re-create things, if there are well-tested solutions up on Packagist.

    • http://twitter.com/jeff_pz_cr Jeffrey Briceno

      Laravel is not amateur, just is a new.
      Laravel is easy to use like codeIgniter but more powerful.

    • http://gabrielmanricks.com/ Gabriel
      Author

      I don’t really prefer zend over other frameworks. It has gotten this enterprise label, and it’s more abstracted from the common person.

      I think it’s nice that I can message Taylor about Laravel and actually impact it directly. Try doing that with Zend.

      Ultimately I think their geared towards different crowds (even if they say otherwise). You won’t see a large corporation use Laravel as-is without extensive review.

    • Wouter J

      I agree on you. This is a great blog, but it is a bit to ‘laravel is fantastic’ blog. Why don’t you create some articles about other frameworks?

      A framework that has nothing else than just static methods just isn’t the reason why 2013 will be ‘the year of php’. If you want to make more money to put the word ‘laravel’ on each page of your blog, please do it in a add or something like that, don’t spam your articles with it.

      • jeff_way

        In the last two weeks, we’ve covered the following frameworks: Laravel, Backbone, Rails, a makeshift framework, CodeIgniter, and Flask. Not sure what you’re talking about.

      • Panos

        You’ve covered about those frameworks but you haven’t covered about Zend Framework 2, CakePHP or Symfony 2 which are the most widespread frameworks for php

      • marco brando

        it is because laravel is the main sponsor for nettuts, get over it, pal !
        if you want to find other php frameworks topics other than laravel, nettuts is NOT the place for you

    • Will

      Laravel really is very nice. Don’t dismiss it just because its trendy. It hits a sweet spot because its fairly simple to get going with (come on, Symphony & Zend are hard to get into) is easy to integrate with stuff from other projects (eg symphony components) has some lovely syntax & is much more capable than codeignitor – for example its got a much better ORM. no that doesn’t make it revolutionary but it is a very nice evolution from CI and probably Cake & some others as it becomes more stable & capable.

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

    Great article. Until php stop being so useful and easy to grasp for not only developers but for disigners as well, it will always going to be in the top choice of anyone that wants to get involved in web development per se.

    • http://twitter.com/jeff_pz_cr Jeffrey Briceno

      Y eso sucede porque php es un lenguaje creado para la web,
      ok ruby es genial, pero si requieres solo una simple aplicacion para enciar mails, con ruby ocupas tener toda la funcionalidad que da rails para crear algo que en 10-25 lineas de codigo lo puedes hacer con php.
      Asi que tienen mucha razon, php es la primera opcion para crear aplicaciones para la web

      And that is because php is a language created for the web,
      ruby ok great, but if you need just a simple application for enciar mails with ruby squatters have all the functionality that gives rails to create something that in 10-25 lines of code you can do it with php.
      So you are quite right, php is the first option to create applications for the Web

      • Andy

        You can do the same in Ruby too in an even shorter amount of code. You seem to think Ruby = Rails. It does not. They are separate things. That’s like saying that PHP is terrible for small applications because codeigniter is too powerful for the job.

  • http://twitter.com/DavidVII David Becerra 

    I’ve been using PHP most of my days and have recently jumped over to Rails. That being said, I’ve been keeping track of Laravel and have tried some of the tutorials here on nettuts. I actually really dig it and I’ll be keeping an eye on it.

  • Simon

    Good article!

  • chp

    When I entered a python or ruby IRC and asked about this or that and somehow mentioned I have past PHP experience, private chats popped up where people quoted “A fractal of bad design” and even personal attacks occured (try it yourself in #python!).

    I think every PHP developer has a story like this to tell. And that leads to a serious problem: Because PHP developers never where taken serious, PHP adapted concepts from Java, because Java is known as a serious language. I think, one of the reason to take Java as prototype for OOP implementation is that everyone wanted to say: Hey, but we are serious. Don’t bully us. We’re like Java! But Java is compiled.

    Hence, PHP developed to a somewhat overengineered language with stuff that matters more in compiled languages (like Interfaces) instead of adding stuff that would matter more in dynamic languages (like ducktyping, monkey patching or a modular system).

    This leads as well to new inconsistencies, as Java is a mono-paradigmatic language and PHP is a procedural core, stacked with an OOP that looks like Java. Hence, we have Type Hinting for Objects and Arrays but not for primitives.

    We have a rising horror of DocAnnotation Configuration inspired by Java, even if we all know that it is damn slow. Other languages like python have powerful class introspection and built in annotations because they focus on what’s a favor for what’s cool in dynamic languages and they do not focus on how to rebuild a compiled language in a dynamic language.

    We have traits, hat are essentially mixins (as in ruby) or multi-class-inheritance (as in python). But without state and resolved at compile time (resolving at compile time equals tightly coupling).

    In other words: PHPs adoption of Java’s OOP has lead to many restrictions that do not really have a point in dynamic languages, but it steals many of the freedom that comes with dynamic languages.

    That’s one of the main problems, PHP is faced with. A developer knows, whether needle or haystack is first in strpos(), so that’s not a problem. The OOP implementaion is not elegant, and that’s a problem.

    Let’s focus on features that reminds us that dynamic languages gives us freedom.

    • Patkos Csaba

      I perfectly agree with you. I am long-time PHP developer and I wrote a lot of articles here mostly in PHP. I program in PHP 8 hours a day at work so I can say I know it pretty well.

      PHP’s big problem is that all of us is using it as an object oriented language, but PHP is no such thing. You will find in the official PHP documentation stated clearly that PHP is not an OO language. It mimics some aspects of OO and that’s why we expected it to behave like other hard-core OO languages like Java and Ruby or Python.

      Than there are the inconsistencies. You said it’s not a big deal to know if haystack or needle is first. But than you have eternal change in order between parameter and callback. Than you have array functions, half of them start with “array_”, the other half doesn’t. Same with string functions, some start with “str” other don’t. These inconsistencies are so random that without a smart enough IDE there is no way to program in PHP without constantly looking up documentation.

      Finally PHP needed an eternity to implement basic things like someArrayReturningFung()[0] or new SomeClass()->aMethod()… and even today, you can’t obtain the last element of an array without actually assigning it to a variable.

      So, I can just hope that there will be day when PHP will be OO and it will not be too late.

      • http://twitter.com/pascalchevrel Pascal Chevrel

        “You will find in the official PHP documentation stated clearly that PHP is not an OO language.”

        Can you give a pointer to that documentation because this is clearly FUD and it seriously undermine your claim of being an experienced PHP developper.

        Here is what the official PHP documentation says:

        “Starting with PHP 5, the object model was rewritten to allow for better
        performance and more features. This was a major change from PHP 4. PHP 5
        has a full object model.” http://php.net/manual/en/oop5.intro.php

        Yes there are inconsistencies in the language about function names and specifically with arrays , but seriously, you are an experienced PHP programmer and you can’t remember those while doing PHP 8 hours a day?

        As for the last claim, this one is just ridiculous:

        “and even today, you can’t obtain the last element of an array without actually assigning it to a variable.”

        You spend all your time in PHP documentation and you don’t know end() which dates back to what? 2002 ?

        $names = ['Joe', 'Jack', 'Mary'];
        print end($names);

        http://php.net/manual/fr/function.end.php

      • http://twitter.com/davidhmcguire David H. McGuire

        Brace yourselves, The war will begin.

    • Quip

      Since when compiled languages do have copyright on “things like interfaces”. Interfaces are just abstraction tools. I’m happy with PHP’s OOP design, and I wish it continues to do so. As a C++ developer in the past, I find it really clear and flexible.

      • chp

        Interfaces do not abstract anything, they do sign a contract.

      • chp

        … offer a contract … pardon my english

      • Quip

        I’ve mentioned ABSTRACTION, meaning that it doesn’t have ANYTHING to do with compiled languages. You use interfaces for design, not implementation.

      • Patkos Csaba

        It depends how you look at interfaces. They are actually the most abstract form of code, followed by an abstract class and than classes. They are abstraction by the way they “sign the contract”.

      • Superoim

        +1

      • Superoim

        I would disagree… They abstract the behaviour of an object for the consumer class. To me, it IS an abstraction tool! I would even say that interfaces are very similar to abstract classes.

        As a side note, I see the concept of Interface itself as an abstraction of shared behaviour.

      • chp

        Hm, my last comment did not save, so I can take the chance get more in to detail :)

        Interfaces are not abstraction tools, they offer a contract. A binding contract is needed in strictly typed languages to permit essential OOP paradigms like composition over inheritance – because the contract has to be fullfilled at compile time. Hence, I did not say that interfaces are copyrighted to compiled languages, I just said that they are of more use there. In a dynamic language, the contract is fullfilled at runtime (where you would see the error anyway) and takes away some of the freedom of a dynamic language. Hence, why not take a compiled language in the first place?

      • Quip

        I see your point, but not completely though. I thought everybody’s happy now with type hinting in PHP, when one knows for sure that he can use some class’s methods, if latter implements interface.

      • chp

        He could know wheter he can use some class’s methods if he would look at the source. Anyway, I’m using interfaces as well in PHP, they are great for readability and clean code. But I would prefer if PHP would focus more on dynamic aspects in the future.

    • http://gabrielmanricks.com/ Gabriel
      Author

      This is also pretty controversial, because isn’t PHP the language? their are plenty of different engines that run it.

      For years JavaScript was an in-browser language and node came along and changed how we thought of it.

      It seems like this is more of a interpreter issue. What do you think?

      • MPinteractiv

        nope ,nobody sane would use php outside of php interpreter. Node exists because it uses v8 that is javascript powered , that’s the only reason. Node creator didnot used javascript because he liked javascript but because it was cheap enough to work with.

      • Gabriel Rodrigues

        That’s completely wrong. Node creator chose javascript for how it handled functions as first class citizens and how it had no concept of threading.

      • MPinteractiv

        Just check youtube conferences with node creator , he clearly stated he doesnt care about javascript. He cares only about writing servers , and using v8 for it’s scripting capabilites was the easiest way to do it. He doesnt give a damn about javascript.

      • http://twitter.com/TheHydroImpulse Daniel

        ^^ Fact!

    • http://twitter.com/TheHydroImpulse Daniel

      Java is not compiled per-say. It’s only compiled into byte-code which is run through the JVM on run-time. The JVM will interpret and JIT the given byte-code. That’s a big difference compared to a normally machine code compiled language.

      • chp

        “Java is not compiled per-say. It’s only compiled into byte-code.”

        It’s not a refutation, when you say that something is NOT COMPILED, because it’s ONLY COMPILED.

      • Superoim

        Daniel meant compilation as “translated into machine language” and not “translated into another language”, hence the “per-say”

      • chp

        I got that :)

      • http://twitter.com/TheHydroImpulse Daniel

        The specifics are important. You can’t really say Java is compiled in the traditional sense as people who talk about compiled languages, (at a low level) talk about machine code. Java is rather being interpreted/JITed which makes a huge impact on performance and flow of execution.

      • chp

        I did not say “Java is compile in the traditional sense”; I argue that Java is compiled in the sense of “the source is translated into something else and during this translation there is a hell lot of code checking going on”. Whether it’s compiled to bytecode or binary code just does not matter in any way for this discussion.

      • http://twitter.com/TheHydroImpulse Daniel

        well it does. Most people don’t know anything about byte-code vs machine code, and so when you talk about X language being compiled, they’ll assume it’s machine code. Typically compiled languages are faster, but that’s when it’s compiled to machine code, people would wouldn’t assume it’s byte-coded. So yes, it does matter. You would instead call Java a transpiled language, similar to CoffeeScript. “A compiled language is a programming language whose implementations are typically compilers (translators which generate machine code from source code)” – Wikipedia. As a result, Java is NOT compiled but transpiled.

    • Christian

      You’ve essentially summed what has been my major complaint about the language for years: PHP wants to be a statically/strongly typed so badly that it actually forgoes the benefits (and pleasures) of working in a dynamic language.

  • http://twitter.com/doobinay Bastien Chamagne

    Composer will change the way we’re doing complex application in a good way. It reminds me of OSGi in Java.

    But for the rest, there is nothing new…

    • http://twitter.com/pascalchevrel Pascal Chevrel

      I am sorry to disagree, for example the integrated developement server in PHP 5.4 totally changed the way I code my projects in PHP, significantly shortened my developement time and more generally made PHP development a lot more fun. To the point that I even contributed several patches to it in PHP.

      Some other recent php features are also nice but unfortunately most of my projects are on PHP 5.3 servers and I can’t use them yet.

  • Kirsten

    Thanks for the post.

    Can I ask why there is no mention of behaviour driven development (BDD)? That’s going beyond TDD and is probably more relevant with a lot of web applications using PHP. There’s now some good work in this area. Check out phpspec2 and Behat. We use these for all our PHP development over at uvd.co.uk.

    Ref:

    http://behat.org/

    http://www.phpspec.net/

    • Quip

      I double on that. I also have a question, as being a complete noob in BDD. Can it be used to completely forget about phpunit/selenium?

      • Kirsten

        Check out the links in my post, these will help. And yes, you don’t need to use phpunit

    • http://gabrielmanricks.com/ Gabriel
      Author

      Correct me if I’m wrong. but wouldn’t BDD be done after you write your code.

      For some reason in my head I would use PHPUnit before hand then write my code and finally write behavior tests last.

      • Kirsten

        Nope. Always write tests first! Check out the links and read up on BDD, Behat especially:

        “With BDD, you write human-readable stories that describe the behavior of your application. These stories can then be auto-tested against your application.”

  • maxw3st

    PSR-O “standard mentioned above” ? Search of the document doesn’t agree. What is PSR–O?

    • http://gabrielmanricks.com/ Gabriel
      Author

      I mentioned PHP-FIG, PSR-0 is one of their standards. I probably should have been more clear about that.

      • maxw3st

        Which still begs the question, what is PSR-0. When I was taught science, I was trained never to use acronyms and jargon without defining it. Apparently that’s a consideration that’s absent from the web development community.

      • http://twitter.com/pascalchevrel Pascal Chevrel

        https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md

        The PSR-0/1/2/x (Proposed Standard Recommandations) are coding standards used for interoperability of framework and they are more generally becoming the coding standards for PHP development in general. Each PSR deals with a specific matter, for example the recent PSR-3 defines the logger interface.

        Accepted PSRs:
        https://github.com/php-fig/fig-standards/tree/master/accepted

  • http://mupkoo.com/ Mirko Akov

    PHP is really about freedom. You can find your own way of doing things and you can end up building web applications in no time, for no time.

    You can write your queries in your HTML or you can get a framework of your choice and make it work like you want it to work. And there are a lot of frameworks to choose from that will match your style or even your mood at the time.

    So it is really about the community. And we don’t waste time hatin’, but lovin’ all the new things that are available almost every day.

    We share, collaborate and push forward, thats why PHP grows

  • Douglas Starnes

    I have used PHP in the past and still do for some small apps. My problem with it is that many of the features feel like afterthoughts. The language wasn’t intended to survive this long is how I feel at times. That being said Composer, Laravel and Eden are very attractive. Many of the language shortcomings can be ameliorated through tools and frameworks such as those.

    • Patkos Csaba

      Yep. PHP was never meant to be as big and sophisticated as it is today. This is one of the reasons there are so many inconsistencies in it.

  • Kris

    I’m growing increasingly tired of the quantity of “let’s defend PHP” articles popping up here. Sure, highlight the up and coming features and libraries in the PHP ecosystem. But please, stop trying so hard to sell PHP. Yes, we know PHP can be used to write scale scalable applications, we also know PHP isn’t the slickest language and the community is looked upon as amateurish. These perceptions / misconceptions exist, if a Ruby / Python dev takes the higher ground, so what? You can make a great application in a variety of languages. Now let’s move on and focus on improving the skills of beginners, web development best practices, pitfalls to avoid, etc.

    • BrianFrichette

      I agree wholeheartedly, and this one in particular was poorly constructed and argued. It reads like partisan propaganda, mixed with shallow dismissals, mixed with a childish tone.

      PHP has one real advantage: Market penetration. And while, I’m actually happy for the PHP community for the fact that PHP has learned over time from much smarter modern languages, projects, and patterns, and from many of its past mistakes, I don’t need this sort of self-congratulatory trumpetting on every other post.

      • Superoim

        Well, it has to sell the network+ premium content…

      • http://twitter.com/LewisCowles1 Lewis Cowles

        Sorry as someone that is paid to develop in PHP, Python and NodeJS, with over a decade of web design and development experience, I think both of these comments are actually more childish and unhelpful than even the ones that deliberately hate against something as arbitrary as the PHP programming language.

        Yes PHP has penetration, which also means it has a wider testing base, than some of it’s competitors, a wide array of extensions, libraries and frameworks to choose from. PHP also has many developers (which I recognize does not speak for quality), and a history of providing a well-rounded means of expression, even for complex applications (not going to cite facebook, as it is not that complex, but certainly some of the applications I have worked on have handled everything from finances, to booking meetings and appointments, taking backups, scheduling automated events, working with audio and image data and ensuring compliance to specifications like OHSAS and ISO.

        Sure my python projects tend to be cool also and although fledgling, I am also finding node a dream to work with. Don’t blame something as simple as the hammer or screwdriver for your own ineptitude at choosing or using the right tool in the right way. Don’t always use the same tool and don’t be afraid to use an expert to do things you can’t and then learn from their code.

        Oh and on the childish part, it is true that PHP coders are more laid back because we do not have to wade through reams of code just to find dropped pointers, de-referenced vars or worry about the underlying nuances of the machines they work with. So on behalf of all Professional PHP Coders everywhere we forgive you for thinking we are immature, we have just not forgotten how to laugh yet…

        Great article, I’ll have to look into eloquent, any articles on its overhead?

        Oh one last thing (just to play devils advocate) Ruby… Seriously pffft

      • Steven Cahay

        Almost every person that I know and work with professionally (including myself) with 10+ years of development experience across multiple platforms and technologies who currently work in Python / Ruby / Go first came from using PHP on the web. You will find that 0% of those (including myself), which is the same with almost anyone I talk to, think that PHP is a ‘better’ language for *any* job. The fact that you aren’t aware of this means that you’re ignorant in anything other than the language you’re ‘comfortable’ with.

      • Gabriel Rodrigues

        Anecdotal evidence is worth shit. I’m a web developer with 10+ years of experience and sometimes I choose PHP. The only language I dislike is Java, but that’s not really due to the language, and more due to the myriad of broken projects I’ve had to fix that were written in it.

        You must be working on a Ruby shop to find all those PHP haters!

      • BrianFrichette

        Let me get this straight.

        You begin by stating the length of time in which you have been paid to write code, presumably in an attempt to bolster the credibility of your baseless argument that you consider our comments more childish and unhelpful than comments which deliberately and arbitrarily HATE the PHP language.

        I’m hoping by the second paragraph you will be able to clarify this empty statement. Instead you launch into a series of bullet points defending the PHP language, something neither Kris nor I disparaged, and the facts of which were never in contention. I agree with these points. Yet they are defenses against arguments that we never made.

        The rest of your post is truly a gem:

        - You think Python is cool
        - You think Node is a dream
        - You analogize PHP (or perhaps programming languages in general) with simple hand tools
        - You broadly categorize hundreds of thousands of people (PHP developers) as being more temperamentally balanced than the rest of us

        Finally, you end by targeting one of the most powerful and expressive languages ever invented, and do exactly what you yourself called childish in your opening paragraph.

        Based on your vast experience, of course.

        You sir, have made yourself quite clear.

    • http://twitter.com/pascalchevrel Pascal Chevrel

      For one pro-php article, I get at least 3 or 4 anti-php articles in my news feed (and I think that both the pro and anti articles are equally biased and generally bad quality ;) )

      I agree that the goal should be to create stuff that is useful for people, that’s what the web is for :).

    • Leric Zhang

      This kind of post is important, because a great portion of php developers still haven’t aware what the language they are using have become into, still cutting logs to buiding there own wheels. I’m in a company using PHP in China, but I’m still the only one that understood the value of Composer.

      Change is coming, people need to know that

      • http://www.facebook.com/asifsaif90 Aasif Saifuddin Auvi

        I agree with you!! the scene is same here in Bangladesh

    • K.C. Hunter

      Entirely agree. Better coding practices trump the language you choose to write in.

      http://www.cartondonofriopartners.com

  • Andrei Zisu

    Hey, python dropped the bad features. They now have python 2.7 and python 3. And they are slowly moving everything to python 3. PHP is expected to do that for a couple of years now.

    • chp

      Python is not running 90% of the internet. Turns out that matters when it comes to backwards compatibility.

      • Andrei Zisu

        Let’s do it this way: realease a proper PHP version not caring about backward compatibility. Now watch how people adopt it because it is so much better!

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

    PHP is not Object Oriented is Object Capable.

  • MPinteractiv

    PHP needs clean API’s first and foremost. It still smells to much like C functions thrown together in a bag , with some C++ syntax. That what matters the most in my opinion. Trim the fat , create a minimal STL , and throw everything else into extensions.
    Thumbs up for the Composer guys , the Doctrine guys and the Symfony Project, they made php bearable.

  • Gabriel Rodrigues

    I just hate it when people automatically presume “Object Oriented” is automatically better than anything else.

    Newsflash, guys: There’s room for procedural programming too!

    In fact, I’d go even further and say that since PHP is a shared-nothing architecture – that ultimately throws away everything upon reaching the end of the script – it’s actually DETRIMENTAL to performance to code in OOP (since the overhead of creating multiple objects is wasted – you can’t cache them using native features, unless someone has a crazy hack?).

    The nice benefits of objects are better organization and module independence, but keep in mind nothing is preventing you from adopting KISS and DRY in procedural programming.

    Also, many people don’t even know PHP itself. It’s a toolbox, for crying out loud! It’s not supposed to do EVERYTHING web-related! I’ve lost count of how many java projects could’ve been done in PHP for a fifth of the cost (including maintenance), and how many PHP projects are being started right now that should have been made on node (as an example). I also know a few developers who fell into the trap of “let’s code our system from scratch, but this time in RUBY!”, lost a ton of money and ultimately reverted back to PHP (does that mean ruby is bad? No. It means jumping on bandwagons without thinking is bad).

    Most people know only PHP – when all you have is a hammer, everything looks like a nail!

    Then come the frameworks. Unhappy, many newbies don’t even bother learning how the language works… so it’s cakePHP this, Zend that, Laravel something else… hell, the problem with most poor programmers is that they don’t bother learning the language. So when confronted with a problem they can’t (or are unwilling to) solve, they just google for a framework. Frameworks have become the new copy+paste. Want an example? All that ORM bullshit. Yeah, it’s nice for small toy projects, but as soon as you have a real database that actually does things, your ORM becomes a hindrance – it’s easier to code straight SQL than properly “mapping”. Again, there are times when using frameworks can provide a huge boost to productivity, but it has to be a conscious and well thought decision. Don’t cram some random framework just because it’s the only one you know!

    Also, about all those frameworks that abstract the language to make it look like something else: I’m sorry guys, if you want to code in ruby, go learn ruby, don’t cram some abomination into PHP to dress it up as something it was never meant to be! It’s the same as those CoffeScript fools, all you’re doing is inviting vendor lock-in and depriving yourself of learning the beauty of the [pure] language that lies within!

    It appears that nowadays, the only thing you hear on programming is Agile/Scrum/Jira , Unit Testing, Cloud computing, etc – yet when you look at the people who produce code that actually makes money, you’ll rarely see any of that. You know why? Because if you try to sit down and study *ALL* the new fads, you’re either going to know next to nothing of each one of them, and when coding a project you’ll be paralyzed due to conflicting best-practices, or you’ll spend all your time studying and zero time producing code.

    Again, there’s a place for all of those, but it’s not *ALL THE TIME*. This is starting to look like a Dilbert comic, programmers running around implementing whatever new buzzword the PHB learns!

    • Runchata

      Oh the guy that figured out everything. Give him the internet.

    • iDontEven

      may god have mercy on your soul

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

      Agree about 10% of what you say.

  • ferisoft

    Its kinda funny when I read some of those articles on here. It sounds like Laravel is your sponsor or something LOL. Anytime I read an article why PHP is good I see Laravel being mentioned. Let me join on that…PHP is not going to be better or worse because of Laravel, thats first. Second Laravel is nowhere near as mature as some of the other major frameworks like Zend or Symfony, so I wouldn’t personally use it in a mission critical app. Third, I dont even get whats all the fuss about, I have used almost all popular PHP frameworks in one way or another so I dont actually see Laravel as breakthrough as you guys usually describe it, its just a regular framework, nothing too fancy about it, as of version 3 it looks very similar to Yii framework in terms of ease of development and functionality it provides to the developer. Personally I think Symfony2 (or the Symfony2 components for that matter) is something much much more flexible and production ready, so Id generally pick symfony2 over Laravel 9 / 10. Some argue, well symfony is so complex its not worth the hustle of learning. Oh well if you have no idea of structuring your code and no idea of best practises then yes it might be. But if you have any remote idea of programming you will see that Symfony2′s dev pricinples are pretty close to something like Spring MVC in Java, so for someone familiar with programming principles its a breeze… For someone with no idea of interfaces and abstraction, probably not so easy, but id advice him to learn about that stuff before doing any serious dev work… Again I have nothing against one or the other, etc. I just find it offending how you constantly push Laravel as the “coolest PHP thing around”, when lets face it its just YET ANOTHER FRAMEWORK, it doesnt do anything that other frameworks on a similar level dont do (not very mature one also). And that constant argument that Laravel is for PHP what RAILS is for ruby is ridiculous… PHP itself is a web framework, it has been designed as such….RAILS is a web framework for the ruby scripting language…there is a subtle difference in there…

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

      Do you think it would be helpful for the PHP community to truly get behind one or two frameworks, rather than embracing a dozen different choices, with varying levels of support?

    • Yii

      do yourself a favor and google “composer”, “packagist”
      if you go back to Yii after that you’re a brave man

      • Feras Salim

        Composer is not framework specific tool, as i noticed I work mostly with SF2 nowadays so im pretty familiar with it. Composer generates the autoloading file for you as well so you can use it in any framework… If I have to put it otherway just answer me this simple question. Why is Laravel so “awesome” and what i has better that other mature frameworks dont? Frankly i dont see it…

    • Joe

      I used several PHP frameworks and created my own framework based on my needs. Personally, I don’t feel Laravel attractive at all. It’s just yet another framework with certain pros and cons. Nothing special. At least I don’t see Laravel has done anything amazing to support UTF-8 as an alternative to PHP’s native string functions which may cause problems when working with UTF-8 encoded strings.

      • ferisoft

        Yeah usually that is the best approach, unfortunately though for most organizations its good to have some kind of a framework that has all the documentation and support (bug fixes etc) already coming as a bundle, since its incredible hard to educate new staff on an internal framework with poor documentation and supporting and maintaining it can become tedious. For someone working as a single developer that might arguably be the best approach in my opinion…

    • JasonStanley

      I am also confused by Laravel. A while ago nettuts was obsessed with Codeigniter. Now the flavor of the month is Laravel.

      Laravel is almost entirely developed by one guy. It has a rediculously fast release cycle for a framework. While it is making a lot of noise I haven’t heard of big companies using it. What happens with Taylor gets burnt out. Will development stop completely?

      I would say if you want to work with a different framework pick Symfony or Zend. Both are established and have a lot of job opportunities. With Laravel you are hoping it takes off and gains traction. Hell both phpbb and drupal are being rewritten in Symfony…

      With composer 2013 will be a year of frameworks become modulised and more interconnected. If Taylor stays motivated I am sure Laravel will continue to grow but the big winner is bound to be Symfony which is increasing being a standard against which good php is measured.

    • Christian

      Thank you!!

      Eloquent === ActiveRecord::Base + PretentiousNamingConvention

      (Laravel == Rails + Sinatra) !== Innovative

      For christ sakes ppl, do you see the fucking irony of touting the wonders of PHP via a framework (Laravel) that is an obvious clone of another language’s flagship projects.

  • Jake

    Um. Since when is C a functional language?

  • http://twitter.com/TheHydroImpulse Daniel

    I used to work with PHP but have dropped it for more modern platforms (Node.js, Python, Ruby). Python might not be “modern” in times, but it’s a fairly modern language semantic wise.

    I’ll address a few things here:

    Scaling:

    While you can theoretically scale pretty much anything that you want to (given the time and hard work is put in), sometimes it’s just not economical to do so. Again, use the right tool for the job. If your intending on scaling to huge traffic, either concurrent, or not, PHP might not be your first choice. Facebook managed to achieve an outstanding level of scalability with PHP but they are not serving native PHP. It’s compiled PHP code into C++ code which can run at much higher speeds.

    Again, using the right tool for the job. Some people look at Node.js, Python, C, C++ and Java for highly scalable applications; PHP probably isn’t on the list.

    Adoption:

    I wasn’t a fan of the PHP adoption cycle (or lack of). Because of it’s widespread use (though that’s not a good excuse) it’s stayed stale for a while and only now has it been picking up again. I joined the Node.js community because it was young, fast and quick to adopt things (though not too quickly). The API for Node.js is fairly stable now and it has the best package manager hands down. Composer is wayyyy too slow for my taste.

    Lack of Consistency:

    This is PHP’s biggest problem right now (one of them, at least). All their functions have different naming conventions, argument placements, and overall, inconsistent. Languages like Ruby, for example, have strict conventions, and since everything is an object, the syntax is perfect.

    Lack of Control:

    With PHP, you’re stuck with a web platform. You could use it for CLI programs, but PHP doesn’t have many good APIs for dealing with anything but the web. With PHP comes a lock-in to a web server (Apache, NGINX, etc…) which leaves you with limited control. Going over with Node.js and Python, you have full control over the environment. You’re learning a single platform that can target a number of different applications, be it a web server, tcp/udp server, game server, etc… This gives you a bigger bang for your buck.

    • Zurich

      I sure do support you about the scalability issue, as you seem to be one of the FB guys eh? It’s my honor to see you here mr Zukerberg.

      You sound like you’ve seen PHP back in 4′s. It’s been a long time, 5.5 is almost here. Perhaps I shouldn’t be telling you this.

      • http://twitter.com/TheHydroImpulse Daniel

        I’ve been keeping up with PHP’s up dates just out of curiosity. But they just seem to tack on features from other languages which results in a bigger mess IMO.

    • Gabriel Rodrigues

      I’m going to have to agree on choosing Node.js for high concurrency and raw speed, and also on how PHP is excellent for the web but poor for anything else (unlike node which is highly versatile).

      Problems with node is that it’s still a bit immature (APIs keep changing), not as proven (unlikely to be considered in a corporate environment), not widely adopted (hard to find programmers to work with you on a project) and doesn’t receive as much attention from the security community (so it might be full of security issues). Still think it’s a spectacular platform though, and eventually those problems will go away.

      • http://twitter.com/TheHydroImpulse Daniel

        It’s just a little bit immature. The API has stopped changing much as it’s approaching 1.0. I wouldn’t really say it’s “not widely adopted”, you just need to look at the right place. The node.js community is pretty big now, if you’re apart of it, you’ll know were to find developers. The security thing is correct, though. With an “un-proven” platform, the corporate world and the security community might not touch it yet.

  • http://twitter.com/kanuj kanuj bhatnagar

    In the recent years, PHP development (atleast where I live, and there are about 200+ PHP development companies where I live) has been obscured by ready open source packages such as Drupal, Magento, WordPress etc. No one hires for PHP developers anymore, they hire Drupal experts, or Magento specialists. I personally have been doing PHP all my professional life, but the current scenario is building up in such a way that in a few years time developers will probably forget what the difference in include/require is. I’ve personally interviewed PHP developers who do not know how a certain function works in PHP, but they’re sure that they can “make it work” in Drupal/Magento/{Insert Open Source Here}.

    • Gabriel Rodrigues

      Exactly! This was one of the points I was trying to make with my long-winded rant below.
      And don’t even get me started on the Zend/Cake guys (though I get the need for minimalist frameworks)

      • http://www.facebook.com/people/Okeowo-Omololu-Remi/542355222 Okeowo Omololu Remi

        yes its quite true,pple are beginning to more focused on PHP Frameworks than the language itself,having used Yii for a while i find myself scouting the PHP Manual for simple functions.

  • mattsah

    Then there are the developers who say things like this, “Laravel comes with Eloquent, an ORM that completely rethinks everything to do with databases.”

    No, it doesn’t “rethink” everything. In fact, it’s a pretty standard “ActiveRecord” type implementation with generally weak integration points, and what it does, it has historically done poorly: http://scriptogr.am/mattsah/post/accessor-methods-not-just-personal-preference

    • Gabriel Rodrigues

      I can think of lots of ways to “completely rethink everything to do with databases” and end up with crap.

      The only “rethinking” that seems to actually be useful in the database field are the noSQL solutions.

      Everything else is either not a rethinking (cloud database, for instance, is just clustering, which has been around forever) or a bad rethinking (ORM/MemSQL)

    • http://blog.jalcine.me/ Jacky Alcine

      Rethinking in the sphere of commonplace PHP operations..

  • http://www.rejionline.com/ Reji Kumar

    Totally agreed!!! Surely It’s an exciting time to be a PHP developer. Proud to be a full time php developer.

  • Han Boon Kiat

    yuck… this is an exciting time for PHP people stuck in developing yesteryear web sites

    facing down the modern standard of real-time, async/messaging, oauth api, REST services behind heavy single page js applications

    PHP is excessive boilerplate, starved of useful tools, verbose clutter of files, , , , to achieve far, far, far too little and totally unready to face the new challenges in 2013 onwards
    seriously
    doing PHP is for web development is like Perl, Python or Smalltalk

    there will be masochists

    • http://blog.jalcine.me/ Jacky Alcine

      Who taught you how to code?

  • https://twitter.com/xarinatan Alexander ypema

    While I don’t really mean to shun PHP, I do like to point out it’s very slow and very convoluted, with arcane function names and lots of legacy-support features. A language like Python or Ruby or even C# does a lot better job at scalable high performance web development.
    PHP works. And there’s a lot of devs out there that know PHP and know it well. There’s also a lot of VisualBasic programmers out there that really know their shit, a language that suffers from the same ‘stigma’.
    There’s a lot of great PHP and VisualBasic programs, and websites, and it is a easier to use than something like C, but only because it has some pre-written functions and elevates memory management from you.

    I’m not saying the language is “bad” but scalable and fast are not in my list of reasons why it isn’t bad.

    • http://twitter.com/pascalchevrel Pascal Chevrel

      Frameworks are slow, PHP isn’t. Python is very fast too as long as you don’t add Django, same with PHP and its propular frameworks. Even “micro”-frameworks for languages (Silex, Slim, Sinatra, Flask…) slow things down more than significantly. The big advantage of PHP is that you can quickly build a website that scales very well without a framework, something that I can’t really imagine with Python for example (and if you don’t like the Django monoculture, you are not going to enjoy building stuff on the web in Pytnhon).

      You can’t say that PHP is not scalable when most of the web run on PHP and that includes hundreds of thousands of sites that have millions of users per day. Actually, most of the time the language is not the bottleneck, the database and the server are, I even ran a website for several years that had up to 2 million visitors a day for an open source project with a small recycled server that cost us 40€ (the cost of the taxi ride from the company office that gave it to us instead of ditching it in the bin).

      • http://twitter.com/TheHydroImpulse Daniel

        Scaling completely depends on some factors. What time of website is it? What content are you sending? Real-time? User Generated Content? ….

        If you were just running a blog, or information site, meh, I wouldn’t call that scaling. If you were dealing with thousands of writing requests every second, then yeah, that would be scaling. Reading isn’t usually a problem (though at high scalability it can be), writing is.

        Most of the web might be run off of PHP but that doesn’t mean it’s scalable. Most of the web doesn’t need to scale, as it doesn’t receive enough traffic.

      • http://twitter.com/pascalchevrel Pascal Chevrel

        And most of the writing depends on databases which moves the bottleneck outside of the language itself to the database and/or the filesystem. There are many examples of major sites that scale well with PHP with thousands of writing operations per second and billions of visits per year such as Wikipedia, Twitpic, Facebook, Digg, Yahoo!… And talking about blogs, wordpress.com handles 60 million blogs in PHP, that’s also quite a lot of writing operations even if it is “just” blogs.

        Does it mean that PHP is the solution to scalability for all projects? Of course not, every project is unique and the language choice is just one of the parameters to take into account to make a project scalable, but you can’t say that language X is not scalable when there is evidence in the open that several of the biggest websites in the world written in PHP started with just a few hundred users and serve now hundreds of millions of users, that is called scalability.

        “Languages, libraries and frameworks don’t scale. Architectures do.”

        — Cal Henderson

      • http://twitter.com/TheHydroImpulse Daniel

        True, but as I said, PHP “can” scale, as anything can be scaled if you know how, but is it the most efficient tool for every job? Probably not. PHP is perfect for blogs, cms’, etc.. because of the widepread of PHP. Blogs however does not generate that many writes, compared to user generated sites (where user generated content is the heart of the operation). A lot of sites are moving away from PHP for a more economical solution that scales with ease and fits into a more modern architecture.

      • http://twitter.com/pascalchevrel Pascal Chevrel

        And yet, most of the examples of sites I put above are sites based on user generated content, one of them, Facebook, being the largest user-generated website in the world.

      • http://twitter.com/TheHydroImpulse Daniel

        Facebook doesn’t count, as they don’t serve PHP but C++. Their PHP code is compile to C++ before deployment. The rest of those sites have hundreds of servers which accounts for any bottlenecks in the language (as scripting languages are a lot slower then compiled languages). PHP, however, is NOT the most economical choice in scaling a huge application. Many other languages support better architectures. That’s my point.

      • http://blog.jalcine.me/ Jacky Alcine

        Facebook DOES count. If that’s the case, Ruby delivers C and Java delivers ASM. C’mon.

      • http://twitter.com/TheHydroImpulse Daniel

        It doesn’t. https://github.com/facebook/hiphop-php . Ruby doesn’t deliver C, it’s WRITTEN in C. BIG difference. For Facebook, ALL their application code is converted to C++ before deployment. C’mon yourself.

      • http://twitter.com/TheHydroImpulse Daniel

        Facebook DOESN’t count. https://github.com/facebook/hiphop-php . Facebook uses this to transform it’s ENTIRE application (code world) code into C++ before it’s even ran or deployed. Ruby doesn’t deliver C, it’s WRITTEN in C. The application code is still written in ruby (for ruby application). Java doesn’t deliver ASM. Java delivers byte-code which is then JITed and interpreted on runtime. C’mon yourself, and get your facts straight.

      • http://blog.jalcine.me/ Jacky Alcine

        So how does Facebook do it?

      • https://twitter.com/xarinatan Alexander ypema

        PHP -IS- a framework. And a very slow one, too, or rather, the interpreter is very slow. Adding even more frameworks on top of that that in the end are just a bunch of prewritten snippets of PHP.

        Really that is not surprising, seeing how the code has to be compiled/intepreted before every page load, python suffers from the same problem and while both can be compiled to bytecode this is a more common practice with python than php. Frameworks/languages that require you to compile to bytecode before it can be executed are much faster, which is exactly what you see happening with Java and C#, both of which are also very web-capable. http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/

        Personally I don’t really have anything against PHP because it’s good for most practices and 99.9% of the reason why an application is good is not the language but the developer, but if you look just at the language/framework, and specifically the scalability and speed aspects you’ll find there’s much much better options. But luckily this doesn’t prevent a dev from writing something amazing. Programming languages are a bit like paint; Trust me, back in the days of Rembrandt and Van Gogh the paint quality was much lower than you get at the average paint store these days, hell, they sometimes even had to make their own paint! Much like in the old assembler-only days, but yet, hundreds of years later we still admire the quality of those paintings, no thanks to the quality of the paint, but the ‘developer’ of the painting.

      • http://blog.jalcine.me/ Jacky Alcine

        PHP is a programming language, who lied to you and told you that it’s a framework?
        If it’s slow, it’s probably because you’re running Amiga machines.

        Compiling to object code can be done with PHP, Facebook open-sourced it.

        Scaling issues doesn’t depend on the language, but on the infrastructural setup.

      • https://twitter.com/xarinatan Alexander ypema

        Personally I’d consider PHP a framework in the same way Java, Python and C# are; it won’t compile to assembler and you can’t run it without the PHP libraries. Yes you can compile it to bytecode which is much faster to interpret, but unfortunately compiled PHP is a niche thing these days.
        Scaling is definitely not just something of the infrastructure. It’s for example much easier to scale up something that’s written in PHP/C#/Java or other ‘framework’ languages due to the fact that the interpreter can decide how it’s being run on the infrastructure, than say something like C/C++, where you have to take care of the scaling parts manually. Scaling is something you don’t just do in hardware but also in code. Yes you can write a VB6 app and when it starts running slow just upgrade the machine but that’s not exactly scaling. And if you’ve ever set up a server to make it more scalable and tried to set up PHP in a proper and safe way with NginX or an alike product you know there’s other languages/frameworks out there that integrate much better such as lua and python.

        Again, PHP is fine for most programmers for the fact it 1) does the job 2) is easier than learning something new and 3) it’s already deployed everywhere so the support is great. Those features are not because the language/framework itself is great, but more of the convenience of the mainstream product.

        PHP isn’t “Bad” but to say as if 2013 is going to be the year PHP will be discovered by everyone and become immensely popular I find far fetched, for one because pretty much everyone knows it already, it’s not some underdog new product that has to fight a way into the mainstream, it’s already mainstream, people are well aware of the fact PHP exists, and secondly, it isn’t that great. It’s good enough and that’s why it’s used, but it’s not something that gets my heart beating faster because of how awesome it scales and how fast it executes, because it doesn’t.

      • http://blog.jalcine.me/ Jacky Alcine

        I still see PHP as a language. It can come with standard libraries and what not, but those would just be considered the standard library. You don’t call C++ a framework because of the STL, no? The STL would be the framework in a sense.

        I do see what you’re saying about the title of the article, but it’s probably a good way to say that things are going to change for the greater for PHP this year.

        Don’t get me wrong, I program in Ruby for a living and C++ and Python for recreation and hobbyist programming so I’ve had my fair share of the “new and hip” and the “legacy tools”. At the end of the day, it’s a matter of doing things properly, don’t you agree? It’s not the language, but the programmer.

  • A Suresh Kumar

    Nice article, Lately PHP newly added features are copied from Java language. This makes me think that most widely used java features are getting added to PHP. Also PHP is easy to start and any one can write code with limited programming knowledge (this is not the case in Java). This makes PHP application less secure and easily hackable.

    We need to create awareness among php developers to improve their coding skills and keep their knowledge up to date by reading blogs, attending Conference and Local PHP User Group Meet.

  • http://twitter.com/Tuwogaka Andrey Gerasimenko

    “transforming into a functional language, like C” Huh? C is a procedural or imperative language. If a rubyist or any other pro hears that, she will simply not here any other arguments, valid or not. This is how stigmas and inconsistencies grow.

  • Sam Abouna

    Yes! Totally agree with Kris and Brian…we get it PHP is not the prettiest but gets the job done…now can we move on?

  • jaen

    “transforming into a functional language, like C,”

    Uh… WAT?
    I think you meant to say “structural”. C is about as close to being functional as to being object oriented.

  • Superoim

    “transforming into a functional language, like C,”
    I hope I haven’t understood that sentence as you meant it… :) C is an imperative language…just in case

    • http://gabrielmanricks.com/ Gabriel
      Author

      I can see the confusion in how I put it. But what I meant is it was more function-oriented, not purely functional as in things like Haskell. Thank you for the clarification

      • Superoim

        I thought you meant it that way but understood it otherwise. I’ll tell my brains to be a little more flexible when I read =)

  • http://twitter.com/orochimaru778 ahmed sherif

    i have been working with php for the last 3 years (or more ?)
    i am sick and tired of it
    other developers do half the work and double the production (like ruby and dot net)
    i am switching to asp mvc4 in 2013 and just maintaining my old php projects
    “so long php”

  • http://twitter.com/ivanhoe011 Ivan Dilber

    The main problem of PHP is that newbies today come with a significantly different background than we used to have 10 years ago. I’ve learned PHP around 1998. after a few years of working with CGI scripts in C/C++ and later Perl/mod_perl, and it felt wonderful. PHP was easy to pick up and far better experience than any major language available for web back then (choice was really just Perl or ASP). Today kids who start with web development have a completely different background. Fact is that if you already know java or C# or ruby or python or javascript (and many learn them at school), you have absolutely no reason to switch to php, on contrary. There is more than enough jobs for any language, the hosting support nowadays is great, all these languages have tones of great features (ok, java still sucks, but..), so I really don’t see why would anyone learn PHP today? Certainly not because PHP has finally added the support for mixins or switched to dot syntax for objects…it’s plain silly… to avoid the future of Perl and many other “old” languages that are now slowly dying, PHP will have to do something far more radical, I’m afraid…

  • http://twitter.com/markszymik Mark Szymik

    Netuts sponsored by Laravel? Haven’t seen anything about Symfony2, which has one of the biggest, strongest and dynamic communites.

  • http://www.facebook.com/leonelsr Leonel Rocha

    one single correction: C isn’t functional at all, C is procedural. Functional languages are the ones without loops etc

  • Sorgfelt

    than, dependencies

  • http://twitter.com/drale2k Drazen Mokic

    When i read “Generators” i thought they would be code generators. I think this is poorly named.

  • bgbs

    I think the war between PHP and Ruby on Training Wheels ended a long time ago. While we are still learning that Ruby exists as a web programming language, if you never heard of PHP by now, you are living in the wrong century.

    I’m not a PHP or Ruby programmer; I’m a web designer, and I work with PHP all the time to design themes. Themng and web design is fairly easy to do with PHP. Is Ruby easy enough to use and understand for web designers not just web developers? Because something tells me that it is web designers not web developers that drove PHP to fame….I could be wrong

    • asecondwill

      This article is more about advanced features of PHP for actual development than templating but yeah Ruby is very easy to do basic things if you are just working in a rails view or a shopify / spree / refinery template or something. PHP & Ruby have some good template languge choices that might make life simpler / more pleasant – eg liquid, haml or twig. Ease of deployment and great opensource CMS projects made PHP popular – more of a dev thing than design.

  • Avelansh

    I dont really get it why there is so much hate towards PHP language.Reading the comments now it appears as though that most of the comments are biased or are based on personal hatred from certain individuals against the language which is really frustrating to watch.I believe that there is always a right tool for a job whether its a PHP, ruby, python etc…

  • Anon

    “we also know PHP isn’t the slickest language and the community is looked upon as amateurish.”

    ^^ and people can keep saying this all they want but guess what? There is not one single language that is ‘perfect’ and bulletproof, and most, if not just about every single successful web 2.0 or startup started on … guess what? PHP. Because its a tool you can get shit done with without much fuss. Later, as your startup or stack matures and needs to scale, you can evaluate its position and move accordingly or just deal with it.

    Facebook still runs PHP, no matter if they convert it to C++ runtimes or not- its still there. With their engineering force they could probably rewrite it quickly in say, Python- but PHP is also dead simple to host and the cheapest to host of them all.

    PHP has many advantages as it does disadvantages as any other language.

    But still, 2013 as the year of PHP is still kinda silly, because without PHP, you could almost say the ‘web rennaisance’ would not have occurred in the early 2000s without it (along with jQuery). Ruby (+ROR) wasn’t there nor was it as accessible or easy to setup locally, same as Python.

    Each of the 3 languages are maturing and there will come a point when they are all equal to one another. THe people dissing one and extolling virtues of another are just adding useless white noise- a lot of us out here just want to build and see other people build cool things.

  • Mr. Blister

    C is not a functional language. C is procedural. You should try out actuak functional programming some time.

  • pixelBender67

    lovin’ 5.5

  • http://www.facebook.com/liaogz82 Moses Liao Gangzheng

    I’m disappointed that the article never mentions anything on HipHop for PHP. Also another beef i have about PHP is the lack of WYSIWYG reporting tools like crystal reports (based on .NET) and BIRT. Also there is no PHP version of Drools planner also rankles me too.

  • Douglas Starnes

    Python is my weapon of choice and I’d use PHP before I’d use Rails. I don’t see why people think the Python crowd sticks with the Ruby crowd. That said, Ruby is more than just Rails but at least I can keep the syntax to PHP in my head. Python in some ways is a more difficult language to use than PHP if you compare it to the C-style languages (lack of a switch statement, indentation required). My biggest complaint about PHP is that it is not a general purpose language. If all you are ever going to do is web then great. When PHP came out you could do web only but today you can’t a lot of the time and need a more general purpose language.

    • Andy

      I don’t get it.. you’re saying PHP’s syntax is more bearable than ruby’s?

  • http://profiles.google.com/florin.jurcovici Florin Jurcovici

    A few years ago (quite some, that isn’t so recent)), there was a joke going around programmers not using PHP: the sets of programmers and PHP programmers are disjunct. That’s from where all the bias against PHP comes.

    Then again, that’s the same story with VB up to VB6.

    However, the distinctions between VB6 and VB.Net are huge. Is PHP going through a similarly disruptive evolutionary process? I’m not aware of it.

    Anything else aside, I don’t think PHP is ever going to rise to the prominence it had a few years ago in web development. Client machines (even phones and tablets) become increasingly powerful, and HTML5 coupled with ever faster JavaScript interpreters make it increasingly easy to move complex logic and UIs to the client, leaving only business logic intensively interacting with the underlying persistent store to run on the servers. PHP may be an easy solution for developing apps which actually run on the server and just display a thin skin in the browser, but it’s IMO not the nicest language/environment for implementing complex logic, and it’s definitely not as fast as other solutions are. This makes PHP sort of a VB6 in this age of web development.

  • http://twitter.com/monkeyonahill James Tryand

    This article is a masterpiece of sublime trolling.
    Gabriel Manricks truly is a comedy genius.

  • Niall

    This article is looking for a debate.

    I suggest reading this – https://www.quora.com/PHP/What-are-the-horrors-of-PHP

    Some highlights:

    - There is no such setting as ‘use strict’, as there was in Perl. Want to have a
    warning if you mistype a variable name? Too bad, that would confuse the
    beginners. If you do enable PHP’s E_ALL warnings, you get warnings and
    errors for all kinds of crazy things you don’t want warnings for.

    - No closures or first-class functions, until PHP 5.3. No functional
    constructs. such as collect, find, each, grep, inject. No macros (but
    complaining about that is like the starving demanding caviar.)
    Iterators are present but inconsistently used. No decorators,
    generators or list comprehensions.

    Other thoughts:

    - Magic Quotes

    - mySQL is depreciated yet here we are on tutsplus and this editor admits using it. How can standards be implemented if the people who should lead the way are stuck using dangerous stuff like mySQL?

    - w3schools

    This is excellent aswell – http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/

    Tutsplus, please stop recommending PHP to developers.

    Yours,

    A node.js, rails, python, javascript and a, when forced, php developer

    • http://gabrielmanricks.com/ Gabriel
      Author

      mySQL is not depracated, PHP’s mySQL driver is depracated. I use mySQL but with the mySQLi library. Hope this clears things up.

  • lol

    HA HA HA HA!