Real quick question. How many of you have heard of PHP? How many of you have heard good things? OK - well, all I can say to that is that the language and community has moved on a lot over the past few years, so hopefully you’ll get a flavour of that
In that time, I’ve seen a *lot* of changes to the language, and I think the most important change is probably what we’re talking about today - the emergence of composer as the defect dependency management tool
How many of you have used NPM, or gradle or Maven or composer? Great. Then you’ll know what I mean by dependency management.
For those who don’t it’s simply a tool for getting dependencies (i.e. other people’s bits of code that you want to use) into your project. So if you need a particular version of some library in your project you can use a tool for this, that’s a dependency manager
Dependency Management in PHP before composer
PEAR = installation on a per server basis. Not per site. What if you have 50 sites on there? phpclasses.org = downloading dependencies *myself*. - Unzipping a zip file myself? - git full of stuff no one here wrote? and you don’t want to review? screwups
Different frameworks develop different tools for dealing with dependencies.
So. what does that look like for interoperability and standards?
Great! Moving between two projects in the same language but with different coding standards is not fun
So - we had silos, each framework gathering a community around itself which didn’t really have a reason to get involved with any others.
I know what you’re thinking… Well, PHP started up as a small project to solve a set of problems for Rasmus Lerdorf - and became a complete language over time.
It grew into the position. Not like GO, for example which was conceived to be a full language, it just became one, eventually.
So, in 2012, we had problems, thankfully, there was infact three separate projects which changed everything…
I maybe should have called this talk “How about half a dozen things including php 5.3’s namespaces saved PHP”, but that’s beyond the scope of this talk.
Composer did 4 things right Installation was per site Autoloading was free! Programmatic including of packages // 2 files [improving on PEAR] installation per site, not per server Good if you have shared hosting, which in 2012, you probably did!
This isn’t all of it, it’s simply a section thereof
So, here’s how straightforward it is to insert a new library, this is a gif of me installing a csv library into a project I’m working on.
So once you’re done - here’s every change you need to commit. You don’t commit the dependencies themselves, just how to get them
SYMFONY COMPONENTS are the BEST!
The result of having great components that are written with composer in mind, and which are small is clear.
Symfony is everywhere.
That’s pretty impressive. It’s amazing that Symfony can be in all these projects. I don’t even know what they all are.
WHAAT?????? This isn’t even exhaustive. Symfony Components have found their way into more php projects, than boojums have found their way into me.
The PHP Feature Interoperability Group.
The most important PSR (PHP Standards Recommendation) was probably the first one. The now deprecated, but never forgotten, PSR-0.
So, you can see how the cumulative effect of these three projects has had a profound influence over php and brought new life into the language and the community.
The language itself has moved along massively over the same time period, as well, but that’s another talk for another time.
Every framework or CMS that we’ve mentioned so far uses composer in it’s base install, with the exception of Wordpress. This is understandable, as backwards compatibility is massively important to that project.
however, we use a wordpress build in work which actually does use composer, and some very bright people have introduced a tool called wpackagist, so wordpress developers can have lots of fun too.
I want to talk about one more organisation.
The PHP League create some great stuff for php - I think they show a successful template for creating packages
I cannot speak highly enough of flysystem. It’s a wonderful tool for abstracting Filesystems, so that plonking stuff onto S3 or whatever is as straightforward as plonking it onto a local disk. It’s fabulous.
PHP Belfast is a community of local php belfast developers.
I still remember the talk, a few years ago, where Andy Graham created a viable php frameout out of some stuff he found on packagist. A router, a tempting engine and so on. Some other stuff. It all worked together. That talk was huge for my development in php. It was amazing.
Write code for the widest possible number of users If you’re writing something for PyroCMS, try to make it so that everyone using Laravel can use it. If you’re writing something for Laravel, try writing it for PHP first Documentation matters PHP-FIG don’t write code - they describe what the code should be like Make the easiest solution the best solution Composer is great - but it’s successful because it’s easy, lets be honest. The fact that it just solved autoloading for everyone forever was huge. Do what you can to make your solutions easy peasy. Lots of small packages > few big ones If symfony had been one single big lump, it wouldn’t have found it’s way into, pretty much everything. Composer would have been less immediately useful Community matters None would have mattered if the php framework developers hadn’t bought into composer
If you photograph that on your phone, you’ll be taken to this slidedeck.
How composer saved PHP
HOW COMPOSER SAVED PHP
OBLIGATORY “ABOUT ME” SLIDE
➤ Worked as a web developer since 2006
➤ Have used several in-house and OS
➤ Involved with phpBelfast
➤ Currently work for The Tomorrow Lab
SUMMARY - SILOS
➤ Diﬀerent Coding Standards
➤ Diﬀerent dependency tools
➤ How to write something for both, say, Laravel & FuelPHP?
➤ Where do you put it?
➤ Are you creating two entirely separate repos?
“Originally used for tracking visits to his online
resume, he [Rasmus Lerdorf] named the suite of
scripts "Personal Home Page Tools," more
frequently referenced as "PHP Tools."
- php.net history page
“The PHP community needs to get together
behind a new solution and the framework
developers need to lead the charge.
- Phil Sturgeon, 2012
PROBLEMS COMPOSER SOLVES
➤ Installation per site
➤ Not curated
➤ But packagist.org helps ensure quality
➤ Tests part of composer.json
➤ PSR-0 Compliant Autoloading solution
➤ Now PSR-4
➤ Don’t have to commit every ﬁle in some library
PROBLEMS SYMFONY COMPONENTS SOLVE
➤ Great Libraries
➤ Used in lots of frameworks
➤ N.B. Symfony not a monolith, but a bunch of bits
➤ But I can take those bits and make what I want
PROJECTS USING SYMFONY COMPONENTS
Symfony Full Stack
eZ Publish Community
LESSONS FOR OPEN SOURCE
➤ Write code for the widest possible number of
➤ Documentation matters
➤ Make the easiest solution the best solution
➤ Lots of small packages > few big ones
➤ community matters
GET IN TOUCH
➤ @ryankilf // @thetomorrowlab