1. PHP Reset
Jordi Boggiano @seldaek
http://nelm.io/
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
2. Disclaimer
This is not about REST
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
3. About Me
Belgian living in Zürich
Weby stuff for 10 years
http://seld.be
Symfony2 core dev and other OSS contributions
http://github.com/Seldaek
Recently started Nelmio
http://nelm.io
We do Symfony2 & Frontend Performance consulting
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
4. Planning
Small Rant
New Frameworks & Libraries
GitHub Commercial Break
Best Practices
Composer
Wishful Thinking
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
5. A bit of history
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
6. PHP4 - 22-May-2000
01 class Foo_Bar_Baz
02 {
03 var $foo;
04
05 function Foo_Bar_Baz()
06 {
07 }
08
09 function bar()
10 {
11 }
12 }
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
7. PHP5 - 13-Jul-2004
01 class Foo_Bar_Baz
02 {
03 public $foo;
04
05 public function __construct()
06 {
07 }
08
09 private function bar()
10 {
11 }
12 }
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
8. Could you spot the differences?
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
9. Yet seven years later
~20% of servers still run PHP4
Source: @iliaa's PHP Advent article, December 2010.
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
10. PHP5.3 - 30-Jun-2009
01 namespace FooBar;
02
03 class Baz
04 {
05 public $foo;
06
07 public function __construct()
08 {
09 }
10
11 private function bar()
12 {
13 }
14 }
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
11. Again, not much has changed.
But it changes everything.
BackslashMeansNoBackwardsCompatibility
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
12. We've been sitting on our asses
for too long.
It's time for a change.
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
16. Assetic
Asset management & processing
Combine & Compress JS, CSS
Compile CoffeeScript, SASS, LESS, ..
Re-encode images
All on the fly with cache or pre-processed
Inspired by Python's WebAssets
Shipped with Symfony2
http://github.com/kriswallsmith/assetic
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
17. Doctrine2
DBAL, ORM, ODMs
Document stores (MongoDB, CouchDB,
PHPCR, XML)
Common interfaces allow for interop and
knowledge re-use
Propel2 builds on top of it
Shipped with Symfony2
http://github.com/doctrine
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
18. Monolog
Logging
FingersCrossedHandler for production
Log to files, FirePHP, emails, etc.
Inspired by Python's Logbook
Shipped with Symfony2
http://github.com/Seldaek/monolog
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
19. Twig
Template engine
Automatic escaping
Separation of concerns
(Readability)
Inspired by Python's Jinja2
Shipped with Symfony2
http://github.com/fabpot/Twig
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
20. Gaufrette
Filesystem abstraction
Code once, store files anywhere
S3, Memory, FTP, Rackspace, ..
Transparently cache calls to slow backends
http://github.com/knplabs/Gaufrette
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
21. Snappy
Generates PDF/images from webpages
Uses wkhtmltopdf/wkhtmltoimage
Good example of a small single-purpose
library
http://github.com/knplabs/snappy
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
22. Imagine
Image manipulation
API that doesn't suck
Supports GD2, Imagick, Gmagick
Easily resize, crop, and more
Inspired by Python's PIL & others
http://github.com/avalanche123/Imagine
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
23. Buzz
HTTP requests
API that doesn't suck
Wraps around CURL
http://github.com/kriswallsmith/Buzz
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
24. Goutte
Web Crawler
Supports CSS3 selectors to extract content
Easily follow links, submit forms, etc.
Good example of code re-use (Sf2/ZF2
components)
http://github.com/fabpot/Goutte
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
25. I can't list them all.
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
26. GitHub
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
27. Git will hurt you
Read http://progit.org - it's free.
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
28. GitHub is your friend
No need to track down a developer's
email. Hit fork, create a branch, then send
a pull request
Push code, get immediate attention and
contributors
README.mdown in every repository
200 Symfony2 contributors, still in beta!
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
30. MIT License
Free as in free.
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
31. Autoload with PSR-0
01 // One class per file
02 // First bit should be a vendor name (your project, company, ..)
03 // This should sit in <project>/Nelmio/Bar/Baz.php
04 // WATCH THE CASE!
05
06 namespace NelmioBar;
07
08 class Baz
09 {
10 }
http://tinyurl.com/psr0-standard
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
32. PEAR-style Coding Standards
01 namespace FooBar;
02
03 class Baz
04 {
05 public $foo;
06
07 public function __construct()
08 {
09 $stuff = array('Coding Style');
10 if (true) {
11 foreach ($stuff as $blob) {
12 echo "happy $blob!";
13 }
14 } else {
15 echo "dead kittens";
16 }
17 }
18 }
http://pear.php.net/manual/en/standards.php
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
33. Remember, kids, standards
are NOT about taste
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
34. Testing
Tests are always good, but for libraries
they're a must.
Typing phpunit in <project>/ is all I want
to know.
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
35. Composer
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
36. Package Management for PHP
Mostly inspired by npm and bundler
Advanced dependency resolving
Install project dependencies locally
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
37. Compose great things with small libraries
Rely on proven code to do common tasks
Simplify old APIs (e.g. Imagine, Buzz)
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
43. Namespace adoption, in effect,
opens up a world of
possibilities.
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
44. Open up your mind,
we're not alone.
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be
45. Share your code
and collaborate.
Jordi Boggiano Company http://nelm.io
http://twitter.com/seldaek Blog http://seld.be