Presented by Larry Garfield (@Crell)
We have too much code
in the world
No Silver Bullet
The most radical possible solution for constructing software is not to construct it at all.
— "No Silver Bullet", 1986.
Commercial Off The Shelf (COTS)
The best way to attack the essence of building
software is not to build it at all.
— "'No Silver Bullet', Refired", 1995.
Hey, look, Open Source!
The way to be more productive is to write less code
The way to be more productive is to reuse more code
If a software engineer, a potential consumer of standardized software components, perceives it to be more expensive to find a component that meets his needs, and so verify, than to write one anew, a new, duplicative component will be written. Notice we said perceives above. It doesn't matter what the true cost of reconstruction is.
— Van Snyder, JPL
as quoted in "'No Silver Bullet', Refired", 1995.
Sharing must be easy or it won't happen
Sharing is how Open Source works
Sucking at sharing is how
Open Source dies
PHP sucked at sharing
This is my island
There are many like it, but this one is mine
2% of the web cares
3% of the web cares
18% of the web cares
Who cares?
This was the best we could do
NIH is normal
80% of the web cares
Source: W3TechsThe average PHP programmer has written
2.5 frameworks in his career.
— Urban legend statistics
You're not a real PHP developer until
you've written your own CMS.
Sharing is how Open Source works
Sucking at sharing is how
Open Source dies
PHP is 18 years old
and is finally growing up
First version
function __autoload($class) {
$file = some_logic($class);
include $file;
}
Useful version
spl_autoload_register('myproject_autoloader');
function myproject_autoloader($class) {
$file = some_logic($class);
include $file;
}
If only I my web host offered PHP 5
— Every PHP developer circa 2007
I can't use PHP 5, no hosts support it.
—Developers
I can't upgrade to PHP 5, no projects require it.
—Hosts
We can't drop support for PHP 4, all the hosts still use it.
—PHP Internals
We can't be the first to use PHP 5, we'll lose our users.
—PHP projects
We've decided that we will all be first.
Epic. Win.
Build software better, together
Better than Sourceforge et al by a wide margin.
2013: PHP leads GitHub
class Zend_Form {}
class Application_Form_Guestbook extends Zend_Form {}
class sfForm() {}
Oh PEAR...
class Structures_DataGrid_DataSource_CSV {}
class Structures_DataGrid_DataSource_CSV_Memory
extends Structures_DataGrid_DataSource_CSV {}
namespace Zend\Form;
class Factory{}
namespace Zend\Form;
use Zend\Captcha;
$factory = new Factory();
$captcha = new Captcha();
namespace Zend\Form;
use Zend\Captcha;
use Guzzle\Http\Client;
$factory = new Factory();
$captcha = new Captcha();
$guzzle = new Client();
We're going to have these namespace things,
let's use them the same way for a change!
(Smoke not guaranteed)
<vendor>\Package\Whatever
new \Some\Class\Name_Here();
include_once $some_root . '/Some/Class/Name/Here.php';
new Guzzle\Http\Client();
// require('/some/root/path/Guzzle/Http/Client.php');
Thrown off lists.php.net, moved to Google Groups
Admitted a few new projects
Slept through 2010
Debated a lot in 2011
We need a dependency system!
It's dumb to make it Symfony specific
—Jordi Boggiano
Nils Aderman (PHPBB): libzypp -> PHP
Jordi Boggiano (Monolog): Packagist, front-end for PEAR
Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
I'd say until early 2012 it was pretty unusable, yet people used it. I guess that's how badly it was needed.
— Jordi Boggiano
September 2012
Composer from the ground up
January 2014: 22,000 packages
(Not just Symfony!)
# Quick-n-easy:
$ curl -sS https://getcomposer.org/installer | php
# Global
$ curl -sS https://getcomposer.org/installer | php -- --install-dir=bin
Base manifest file for your project
{
"name": "crell/myapp",
"description": "This app is amazing.",
"require": {
"guzzle/guzzle": "3.4.*"
},
"autoload": {
"psr-0": {
"MyName\\MyPackage": "src/"
}
}
}
Installs all dependencies for your project
$ composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing symfony/event-dispatcher (v2.3.1)
Downloading: 100%
- Installing guzzle/guzzle (v3.4.3)
Downloading: 100%
symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/event-dispatcher suggests installing symfony/http-kernel ()
Writing lock file
Generating autoload files
use Guzzle\Http\Client;
require_once __DIR__ . '/vendor/autoload.php';
// Every class is now yours to command!
// Autoload on demand! Your work: zero.
$client = new Client('https://api.github.com');
$request = $client->get('/user')->setAuth('user', 'pass');
$response = $request->send();
echo $response->getBody();
The organization formerly known as the
PHP Standards Group and now represented by
this web site
Became useful in 2012
Renamed to PHP Framework Interoperability Group,
June 2012
New (first?) actual process definition, July 2013
Standard logger interface
Inspired by Monolog ... and Drupal
namespace Psr\Log;
interface LoggerInterface {
public function log($level, $message, array $context = array());
public function emergency($message, array $context = array());
public function alert($message, array $context = array());
public function critical($message, array $context = array());
public function error($message, array $context = array());
public function warning($message, array $context = array());
public function notice($message, array $context = array());
public function info($message, array $context = array());
public function debug($message, array $context = array());
}
Unified caching interface
Stay tuned... ;-)
The way to be more productive is to write less code
The way to be more productive is to reuse more code
The way to be more productive is to share more code
Drupal needs to evolve, and quickly, from a first-class web CMS into a first-class REST server that includes a first-class web CMS.
Hey, look, a first-class REST server!
Zend ProxyManager in DependencyInjection Component
Great news for Symfony!
Given 2 ways to solve a problem,
choose the approach that results in less code
in the world
We are no longer islands
Our world is changing fast.
Let's go somewhere together.
Senior Architect, Palantir.net
Drupal core developer
PHP-FIG representative
Loveable pedant
Yell at me on Twitter: @Crell
Stalk me professionally at @Palantir