HOW COMPOSER SAVED PHP
OBLIGATORY “ABOUT ME” SLIDE
➤ Worked as a web developer since 2006
➤ Have used several in-house and OS
frameworks
➤ Involved with phpBelfast
➤ Currently work for The Tomorrow Lab
➤ @ryankilf
DEPENDENCY
MANAGEMENT
?
DEPENDENCY
MANAGEMENT IN
PHP IN 2012
A confused mixture
DEPENDENCY MANAGEMENT
➤ PEAR
➤ phpclasses.org
DEPENDENCY MANAGEMENT
➤ PEAR
➤ phpclasses.org
DEPENDENCY MANAGEMENT
➤ PEAR
➤ phpclasses.org
➤ Framework Specific Dependency Management
➤ CodeIgniter - Sparks
➤ FuelPHP - Cells
➤ Laravel - Bundles
➤ Cake - The Bakery
➤ ZF2 - Modules
INTEROPERABILITY
+
STANDARDS
SUUUUURRRREEE
CODING STANDARDS
$variablenamelikeso
$variableNameLikeSo
$variable_name_like_so
SUMMARY - SILOS
➤ Different Coding Standards
➤ Different 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
ENTER
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 file in some library
TYPICAL COMPOSER FILE (SECTION THEREOF)
"require": {
"php": ">=7.0.1",
"doctrine/dbal": "^2.5",
"fzaninotto/faker": "^1.6",
"jeroennoten/laravel-adminlte": "^1.17",
"laravel/framework": "5.3.*"
},
ADDING A NEW PACKAGE TO MY PROJECT
ADDING A NEW LIBRARY
COMPOSER.JSON
COMPOSER.LOCK
ENTER
PROBLEMS SYMFONY COMPONENTS SOLVE
➤ Great Libraries
➤ Used in lots of frameworks
➤ interoperability
➤ 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
http://symfony.com/projects
Drupal

phpBB

Laravel

Symfony Full Stack

eZ Publish Community

Joomla!

Composer

Magento

Piwik

Silex

Assetic

Goutte

Sami

Sismo

PHPUnit

OroCRM

OroPlatform

Doctrine

Behat

Sylius

Sonata Project

Zikula

Symfony CMF

Akeneo PIM

Shopware

Propel

Mautic

Codeception
PROJECTS USING SYMFONY COMPONENTS
http://symfony.com/projects
TYPO3

Thelia

Kunstmaan Bundles

Sculpin

Flow

phpspec

phpDocumentor

Guzzle

Bolt

Pagekit

Vespolina

Easybook

Fork CMS

phpMyFAQ 

PPI Framework

Proem Framework

Sulu

init CMS

Carew

RedKite CMS

Ladybug

Phinx

Elcodi

Spress

phpRedExpert

Roadiz

Mothership

BackBee

concrete5

Sonata e-commerce

Drupal Console

Grav

WellCommerce

Contao

Aimeos e-commerce components

PHP Depend

bowerphp

freepost

Morfeu

Pimcore

CSBill

eccube
ENTER
PROBLEMS PHP-FIG SOLVES
➤ Standards
➤ for everyone
➤ A whole PHP vision
➤ a PHP-first community
➤ Not just a community for every framework
➤ They don’t write code
➤ PSR-0 - most important
NOW?
What’s the current state of PHP?
COMPOSER INFLUENCE
COMPOSER INFLUENCE
johnpbloch/wordpress // roots.io // wpackagist.org
ENTER
THE PHP LEAGUE
➤ Packages for everyone
➤ Which are PHP-FIG compliant
➤ PHP: The right way
➤ “Everyone first”
➤ Adapters for specific frameworks
➤ Flysystem, wow!
PHPBELFAST FRAMEWORK
➤ Now viable to make entire applications out of “Stuff” on packagist
➤ Not convinced that it’s the right thing to do
➤ But, still great that it’s viable
➤ @phpbelfast
ENTER YOU?
LESSONS FOR OPEN SOURCE
➤ Write code for the widest possible number of
users
➤ Documentation matters
➤ Make the easiest solution the best solution
➤ Lots of small packages > few big ones
➤ community matters
FURTHER READING
➤ benramsey.com/blog/2013/11/the-fall-of-pear-and-the-rise-of-composer
➤ philsturgeon.uk/php/2012/03/06/packages-the-way-forward-for-php
➤ symfony.com/projects
➤ roots.io
GET IN TOUCH
➤ @ryankilf // @thetomorrowlab
➤ ryan@thetomorrowlab.com

How composer saved PHP

  • 1.
  • 2.
    OBLIGATORY “ABOUT ME”SLIDE ➤ Worked as a web developer since 2006 ➤ Have used several in-house and OS frameworks ➤ Involved with phpBelfast ➤ Currently work for The Tomorrow Lab ➤ @ryankilf
  • 3.
  • 4.
    DEPENDENCY MANAGEMENT IN PHP IN2012 A confused mixture
  • 5.
  • 6.
  • 7.
    DEPENDENCY MANAGEMENT ➤ PEAR ➤phpclasses.org ➤ Framework Specific Dependency Management ➤ CodeIgniter - Sparks ➤ FuelPHP - Cells ➤ Laravel - Bundles ➤ Cake - The Bakery ➤ ZF2 - Modules
  • 8.
  • 9.
  • 10.
    SUMMARY - SILOS ➤Different Coding Standards ➤ Different dependency tools ➤ How to write something for both, say, Laravel & FuelPHP? ➤ Where do you put it? ➤ Are you creating two entirely separate repos?
  • 12.
    “Originally used fortracking 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
  • 13.
    “The PHP communityneeds to get together behind a new solution and the framework developers need to lead the charge. - Phil Sturgeon, 2012
  • 15.
  • 16.
    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 file in some library
  • 17.
    TYPICAL COMPOSER FILE(SECTION THEREOF) "require": { "php": ">=7.0.1", "doctrine/dbal": "^2.5", "fzaninotto/faker": "^1.6", "jeroennoten/laravel-adminlte": "^1.17", "laravel/framework": "5.3.*" },
  • 18.
    ADDING A NEWPACKAGE TO MY PROJECT
  • 19.
    ADDING A NEWLIBRARY COMPOSER.JSON COMPOSER.LOCK
  • 20.
  • 21.
    PROBLEMS SYMFONY COMPONENTSSOLVE ➤ Great Libraries ➤ Used in lots of frameworks ➤ interoperability ➤ N.B. Symfony not a monolith, but a bunch of bits ➤ But I can take those bits and make what I want
  • 22.
    PROJECTS USING SYMFONYCOMPONENTS http://symfony.com/projects Drupal
 phpBB
 Laravel
 Symfony Full Stack
 eZ Publish Community
 Joomla!
 Composer
 Magento
 Piwik
 Silex
 Assetic
 Goutte
 Sami
 Sismo
 PHPUnit
 OroCRM
 OroPlatform
 Doctrine
 Behat
 Sylius
 Sonata Project
 Zikula
 Symfony CMF
 Akeneo PIM
 Shopware
 Propel
 Mautic
 Codeception
  • 23.
    PROJECTS USING SYMFONYCOMPONENTS http://symfony.com/projects TYPO3
 Thelia
 Kunstmaan Bundles
 Sculpin
 Flow
 phpspec
 phpDocumentor
 Guzzle
 Bolt
 Pagekit
 Vespolina
 Easybook
 Fork CMS
 phpMyFAQ 
 PPI Framework
 Proem Framework
 Sulu
 init CMS
 Carew
 RedKite CMS
 Ladybug
 Phinx
 Elcodi
 Spress
 phpRedExpert
 Roadiz
 Mothership
 BackBee
 concrete5
 Sonata e-commerce
 Drupal Console
 Grav
 WellCommerce
 Contao
 Aimeos e-commerce components
 PHP Depend
 bowerphp
 freepost
 Morfeu
 Pimcore
 CSBill
 eccube
  • 24.
  • 25.
    PROBLEMS PHP-FIG SOLVES ➤Standards ➤ for everyone ➤ A whole PHP vision ➤ a PHP-first community ➤ Not just a community for every framework ➤ They don’t write code ➤ PSR-0 - most important
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
    THE PHP LEAGUE ➤Packages for everyone ➤ Which are PHP-FIG compliant ➤ PHP: The right way ➤ “Everyone first” ➤ Adapters for specific frameworks ➤ Flysystem, wow!
  • 32.
    PHPBELFAST FRAMEWORK ➤ Nowviable to make entire applications out of “Stuff” on packagist ➤ Not convinced that it’s the right thing to do ➤ But, still great that it’s viable ➤ @phpbelfast
  • 33.
  • 34.
    LESSONS FOR OPENSOURCE ➤ Write code for the widest possible number of users ➤ Documentation matters ➤ Make the easiest solution the best solution ➤ Lots of small packages > few big ones ➤ community matters
  • 35.
    FURTHER READING ➤ benramsey.com/blog/2013/11/the-fall-of-pear-and-the-rise-of-composer ➤philsturgeon.uk/php/2012/03/06/packages-the-way-forward-for-php ➤ symfony.com/projects ➤ roots.io GET IN TOUCH ➤ @ryankilf // @thetomorrowlab ➤ ryan@thetomorrowlab.com

Editor's Notes

  • #2 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
  • #3 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
  • #4 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
  • #5 Dependency Management in PHP before composer
  • #6 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
  • #7 Awks!
  • #8 Different frameworks develop different tools for dealing with dependencies.
  • #9 So. what does that look like for interoperability and standards?
  • #10 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.
  • #11 YUCK!
  • #12 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.
  • #13 It grew into the position. Not like GO, for example which was conceived to be a full language, it just became one, eventually.
  • #14 So, in 2012, we had problems, thankfully, there was infact three separate projects which changed everything…
  • #15 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.
  • #17 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!
  • #18 This isn’t all of it, it’s simply a section thereof
  • #19 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.
  • #20 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
  • #21 SYMFONY COMPONENTS are the BEST!
  • #22 The result of having great components that are written with composer in mind, and which are small is clear. Symfony is everywhere.
  • #23 That’s pretty impressive. It’s amazing that Symfony can be in all these projects. I don’t even know what they all are.
  • #24 WHAAT?????? This isn’t even exhaustive. Symfony Components have found their way into more php projects, than boojums have found their way into me.
  • #25 The PHP Feature Interoperability Group.
  • #26 The most important PSR (PHP Standards Recommendation) was probably the first one. The now deprecated, but never forgotten, PSR-0.
  • #27 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.
  • #29 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.
  • #30 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.
  • #31 The PHP League create some great stuff for php - I think they show a successful template for creating packages
  • #32 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.
  • #33 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.
  • #35 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
  • #37 If you photograph that on your phone, you’ll be taken to this slidedeck.