The Fall of PEAR and the Rise of Composer
Pear-ish Fall-ish Composition, by Kasia / CC BY
These four things have been revolutionary for PHP: PHPUnit, GitHub, Composer, and Travis CI.
Amy Stephen, November 25, 2013, Twitter
Palms sweaty, stomach aflutter with butterflies, I stood before my first audience as a technical speaker. It was a time of many firsts for me—my first PHP conference, my first time in Europe, my first technical presentation. I had been accepted to speak at the 2005 International PHP Conference Spring Edition in Amsterdam. I was nervous, jet-lagged, and tired from an all nighter working on slides. My talk was entitled “Framing the Frameworks: What Are They and Do I Need One?” The room was jammed-packed, standing-room only. The recently-coined term rasmussed was being tossed around. I certainly didn’t deserve that level of attention.
After my presentation, I found myself downstairs during the break, discussing the topic of frameworks with a German gentleman. I don’t recall much of our conversation, but after a while, I made the biggest mistake I have ever made in my entire career as a speaker. I asked the question “how did it go?”
“Oh, I think we both know how it went,” responded the gentleman drily.
“No. No, I don’t think I do. Can you elaborate?” My second mistake.
“It was horrible!” he exclaimed.
Wow. I was floored. I had to get out of the conversation quickly. I thanked him for his frankness and excused myself. I found a quiet room and sat down for a while, taking deep breaths, trying to calm myself and recover before giving a second talk that day. If I was nervous before, I was frantic now. I didn’t think I could muster up the courage to give another presentation, but I pressed on, and I’m better for it.
That day, I learned two valuable lessons: 1) after giving a presentation never, ever, ever, ever ask someone how they thought it went; let them volunteer that on their own, and 2) unless you want a brutally honest response, don’t ask a German for their opinion.
In the frameworks presentation, I covered php.MVC, WACT, Prado, and Cake. It was too early for frameworks like Symfony, Zend Framework, and CodeIgniter; they didn’t exist yet. I also covered one other thing: PEAR.
I discussed PEAR as a framework.
In those days, this wasn’t such a far-fetched idea. PEAR was and still is a curated library of (what we hope to be) the best reusable PHP userland libraries. I argued that PEAR could hold all the components of a framework, and we could pick and choose which ones to use in our applications. A front controller here, a router there, a dispatcher maybe. There was no need for a massive, full-stack framework. PEAR had the potential for it all, or so I argued.
But PEAR’s biggest selling-point—the curation of packages by a governed community—was also its biggest problem. There was no choice, and things moved slowly. If a package stagnated in development, I couldn’t find another actively supported one to solve the same need. In theory, the maintenance of the package could be taken over by someone else, but this didn’t always happen, and contributing patches was not clear or easy. Sure, there were other PHP library communities, but these provided packages that were even more difficult to use and install, and code quality was suspect at best.
PEAR2 and Pyrus intended to solve PEAR’s problems, but they couldn’t happen fast enough for an evolving and growing community. Frameworks exploded and proliferated—apart from PEAR—forever changing the face of PHP development, and then something else happened that may have been inevitable but was nonetheless surprising: the framework communities began working together.
At php|tek 2009, a group of leaders from a few of the frameworks and libraries communities got together to, as David Coallier described, “develop a set of common standards which PHP projects can strive towards adopting.” This moment represented a turning point in the PHP community. All modern PHP development hinges on this moment. As the Doctor might say, it is a fixed point in time.
This group produced what would become known as PSR-0, an autoloading standard for PHP userland frameworks and libraries, and the group’s name would eventually become the PHP Framework Interop Group (PHP-FIG). It was this autoloading standard that I think changed the course of all PHP userland development. Of course, it relied on the recent addition of namespaces to PHP 5.3, but it standardized a way of autoloading namespaced classes following a specific directory hierarchy. It ushered in an era of userland class interoperability. Yet, it wasn’t until Composer that the full realization of what we had achieved became apparent.
Composer is what PEAR should have been. Through Packagist, Composer is the democratization of PHP userland libraries. Many libraries in the repository implement similar functionality, but through a show of popularity, the community self-selects the packages that are of the best quality. In doing so, the best libraries bubble up to the top. It’s a Darwinian approach to choosing a PHP library.
Not only that, Composer encourages best practices and standards. It doesn’t do this through any real enforcement, but when I look through packages who submit themselves to Packagist, by and large, they follow similar coding standards through use of PSR-1 and PSR-2, and they often include PHP Unit test suites. So, there’s something going on there—through the examples of Composer, frameworks’ packages, and other libraries, there is a sense of the promotion and adoption of PHP-FIG best practices.
In just a few short years, Composer has revitalized the PHP community and changed the way we do development. There is an excitement around developing PHP libraries that I haven’t seen in years. It gets me excited, and I can’t wait to see where it takes us.
I’m not sure what the future holds for PEAR. As a PHP old-timer, PEAR still holds a special place in my heart, and I have many friends who still care deeply for it. As a part of PHP history, it has significant value. Yet, I can’t help but feel its days are numbered. As it fades away, Composer gains in popularity and relevance. Composer further solidifies the importance of PSR-0 in the PHP community, it allows the community to self-select the best-quality packages, and it encourages best practices.
Nearly ten years ago, I gave a presentation about PEAR as a way to pick-and-choose the best components available for building PHP projects. Today, Composer has realized that goal. I’m excited to see how the community will continue to grow as a result.
11 Comments
Interesting to hear the perspective of one who was there and a part of this transformation. Usually, a combination of events help facilitate radical change and that is indeed what happened with the combination of PSR-0 and Composer.
I'm not sure why but this next step of interoperability doesn't seem as clear. Even FIG seems to struggle for clear purpose. Looking forward, where do you think the PHP community should head from here? What should FIG's role and purpose be? How can the broader community of PHP developers help usher in positive change, just like has been done with the sharing of packages via Composer? Might be a good New Year's Post for some of our community leaders.
Thanks for sharing.
I'm not sure but I think HHVM might the way forward. A PHP implementation that we can build better-than-C performant code in PHP and have it JIT. New extensions can be written (mostly) in PHP.
Once (if?) we get to the point of being able to make changes to the language itself (e.g. adding the splat operator), then so long as we have a good process in place, we can rapidly advance the language feature set.
Certainly, I think HHVM is something to watch!
Thank you for the wrap up! More than 12 years ago I used my first PEAR libs, and I still use some of them. :-/
I remember that conference in Amsterdam - we even met there in person, albeit briefly (somehow the conference organizers forgot to book a room for me and you offered to share yours, but I already had another offer... still, thanks for the friendly gesture :-)).
Two years before, I had my first speaking gig at the same conference. It was quite a nightmare for me as well: I had no conference experience at all, not even as an attendee, it was the first slot in the morning (so I couldn't observe other speakers first - and also, I am not a morning person *at all*), I had almost no prior experience in public speaking and the room was absolutely packed. In addition, my talk was about my old PEAR package DB_DataObject_Formbuilder, which utilized HTML_QuickForm, whose author, Betrand Mansion, was sitting in the first row. Let's just say I was quite close to peeing my pants :-D
All things considered, it didn't go too badly though - but I completely lost track of time, had to go through the last set of slides in a hurry and still needed overtime to finish. Well, I got better during the next couple of years :-)
Anyway, I have very fond memories of PEAR, not just because it was my first experience contributing to Open Source, but also because I learned so incredibly much from it: It was the first time I had to remotely collaborate with others, the first time I had to subject myself to a strict ruleset for organizing code (coding standards, directory structure, PHPDoc comments etc.) and designing an API so that it would be generally useful for a wide number of use cases. Looking back, the end result was still horrible from an OOP purist point of view, but it worked - and at the time, this was what most PHP packages looked like - monolithic and bloated :-)
My point is I wouldn't be half as good a developer today if it weren't for PEAR, and I will be forever thankful for what PEAR and its community did for me.
That being said, Composer and the PSR initiative are awesome - it makes life so much easier. It can be a bit overwhelming to find the "right" packages for a given project, though. Maybe a good successor to PEAR would be some kind of advisory board of "elder statesmen" who curate packages and pick the best one or two from each category, where "best" is rated by a strict set of criteria, like following the PSR standards, having test coverage, playing nicely with others etc.?
Regarding your last comment and the elder statesmen, I would also like if this happened. Especially for fringe things it would be valuable. For routers/MVC/whatever every framework offers, it's less important I think and especially not as easy to debate without entering religious wars about framework X vs Y. But sometimes you need that PDF-generator or an implementation of some RFC I never heard of, and if you find 3 packages with similar levels of non-use it's hard to pick one.
Would be great to see a community-driven gamified type points-system supporting this. I don't think there's value to having a set group of "elder statesmen" pick out things - but I think there's a huge value in letting people upvote packages, with certain peoples vote weighing more. A user-driven meritocracy would be the best way forward, I think.
knpbundles.com scoring system isn't perfect but its a good start. that being said, it also excels for the popular stuff and has trouble with the more niche stuff :-/
This reminded me of a talk I gave 2 and a half years ago at IPC:SE (coincidentally;)). It was about Composer as we just had started working on it. Nobody knew it, or cared much. I was floating the idea of this big reset button of PHP, which is sort of what you described as "revitalized the PHP community". There were 15-20 persons in attendance and it seemed like a hopeless cause. I am glad Composer prevailed in the end, not over PEAR but over *nothing*, which is what most people and frameworks were using back then.
Slides of that talk, for posterity: http://slides.seld.be/?file...
First off: I am a big fan of composer, for a lot of use cases it is a good solution. Especially in the most of common case of a framework application that you develop in a team and want to deploy easily.
But it comes with problems, as it makes it very easy to create libraries with dependencies which can conflict. Some people especially like to require the newest or a specific version of each of their dependencies. As soon as you have a number of these you run into the dependency hell, so popular in cpan, bundler or npm.
It is also a different philosophy, while PEAR packages are usually installed site wide and shared between applications, composer is mostly used for application specific dependencies. That is also the reason why Linux distributions providing PHP libraries base these on the PEAR packages (I am speaking from my experience as Fedora packager here). This makes it also much easier to upgrade libraries with security problems for multiple applications.
That being said: I now moved on to a combination Ruby On Rails and nodejs and I miss the quality of a lot of PHP libraries and frameworks. Rails and nodejs library developers seem to have much more of a drive by attitude to programming, with a lots of abandoned code and lack of testing.
The fact that Composer default to install-lib-for-project and pear defaults to install-lib-for-system is imho where 50% of its "breath of fresh air" (power) lies - with the other 50% being the fact that composer actually has a dependency resolver and pear never had one.
Letting every app developer to specify the version of libs he wants actually removes a huge amount of pain from the shoulder of sysadmins and is the enabling factor in being able to install and upgrade many applications on a single server. So, I'd say that the quagmire of interdependency locking is actually getting improved, not worsened.
True, fixing a security bug system-wide gets harder, but tools such as the free service offered by Sensio might come along helping with that.
All in all, I never looked on php libraries as "system" libraries, but rather as components of applications, and I don't really mind if they get packaged by linux distros or not. Quite a few of them evolve too fast to be managed as stable components of an OS. And the fact that anyone with a minimum of experience can hack a php file using vi to add a fix/workaround for his special need also makes them a "soft" target (but then I'm a developer, hand having a hundred version of all libs and apps a single my laptop is my bread and butter)
I remember that conference well, and I was in attendance for your talk if I remember correctly. You mention that it was too early for frameworks like Symfony to exist, not entirely true as that conference was my first introduction to Symfony (0.6.3 I think) via a presentation by Dustin Whittle. I can still remember our palpable excitement on seeing the developer toolbar for the first time! Other highlights were people complaining that one was no longer able to reassign $this in PHP5, crazy times.
I'm incredibly excited about the potential of composer. I second ggeek in that PEAR was pretty awesome, but could be extremely irritating in its way of handling dependencies on a system-wide basis, composer gives developers the power to control the dependencies that they want for their application on a project-by-project basis. It can free one (to a certain extent) from the vagaries of relying on system admins (or hosting providers) from having the requisite PEAR library installed on the server, de-coupling the application from the environment. Not only that, it can be used to remove a dependency on git submodules (or svn externals if you like) to bring in external plugins/libraries. So, all in all, I see composer as being essential for the management of external dependencies for pretty much all of our projects moving forwards.