Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

international PHP2011_Jordi Boggiano_PHP Reset

872 views

Published on

Published in: Technology
  • Be the first to comment

international PHP2011_Jordi Boggiano_PHP Reset

  1. 1. PHP Reset Jordi Boggiano @seldaek http://nelm.io/Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  2. 2. Disclaimer This is not about RESTJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  3. 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 consultingJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  4. 4. Planning Small Rant New Frameworks & Libraries GitHub Commercial Break Best Practices Composer Wishful ThinkingJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  5. 5. A bit of historyJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  6. 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.iohttp://twitter.com/seldaek Blog http://seld.be
  7. 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.iohttp://twitter.com/seldaek Blog http://seld.be
  8. 8. Could you spot the differences?Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  9. 9. Yet seven years later ~20% of servers still run PHP4 Source: @iliaas PHP Advent article, December 2010.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  10. 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.iohttp://twitter.com/seldaek Blog http://seld.be
  11. 11. Again, not much has changed. But it changes everything. BackslashMeansNoBackwardsCompatibilityJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  12. 12. Weve been sitting on our asses for too long. Its time for a change.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  13. 13. New FrameworksJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  14. 14. Symfony2 Lithium Silex ZF2 ... .Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  15. 15. New LibrariesJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  16. 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 Pythons WebAssets Shipped with Symfony2 http://github.com/kriswallsmith/asseticJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  17. 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/doctrineJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  18. 18. Monolog Logging FingersCrossedHandler for production Log to files, FirePHP, emails, etc. Inspired by Pythons Logbook Shipped with Symfony2 http://github.com/Seldaek/monologJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  19. 19. Twig Template engine Automatic escaping Separation of concerns (Readability) Inspired by Pythons Jinja2 Shipped with Symfony2 http://github.com/fabpot/TwigJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  20. 20. Gaufrette Filesystem abstraction Code once, store files anywhere S3, Memory, FTP, Rackspace, .. Transparently cache calls to slow backends http://github.com/knplabs/GaufretteJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  21. 21. Snappy Generates PDF/images from webpages Uses wkhtmltopdf/wkhtmltoimage Good example of a small single-purpose library http://github.com/knplabs/snappyJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  22. 22. Imagine Image manipulation API that doesnt suck Supports GD2, Imagick, Gmagick Easily resize, crop, and more Inspired by Pythons PIL & others http://github.com/avalanche123/ImagineJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  23. 23. Buzz HTTP requests API that doesnt suck Wraps around CURL http://github.com/kriswallsmith/BuzzJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  24. 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/GoutteJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  25. 25. I cant list them all.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  26. 26. GitHubJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  27. 27. Git will hurt you Read http://progit.org - its free.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  28. 28. GitHub is your friend No need to track down a developers 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.iohttp://twitter.com/seldaek Blog http://seld.be
  29. 29. Best PracticesJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  30. 30. MIT License Free as in free.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  31. 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-standardJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  32. 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.phpJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  33. 33. Remember, kids, standards are NOT about tasteJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  34. 34. Testing Tests are always good, but for libraries theyre a must. Typing phpunit in <project>/ is all I want to know.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  35. 35. ComposerJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  36. 36. Package Management for PHP Mostly inspired by npm and bundler Advanced dependency resolving Install project dependencies locallyJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  37. 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.iohttp://twitter.com/seldaek Blog http://seld.be
  38. 38. composer.json (lib) 01 { 02 "name": "Monolog", 03 "description": "Logging for PHP 5.3", 04 "keywords": ["log","logging"], 05 "homepage": "http://github.com/Seldaek/monolog", 06 "version": "1.0.0", 07 "license": "MIT", 08 "authors": [ 09 { 10 "name": "Jordi Boggiano", 11 "email": "j.boggiano@seld.be", 12 "homepage": "http://seld.be" 13 } 14 ], 15 "require": { 16 "php": ">=5.3.0" 17 } 18 }Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  39. 39. composer.json (project) 01 { 02 "repositories": { 03 "AwesomeLib": { 04 "git": "git://github.com/Jim/AwesomeLib.git" 05 }, 06 "GreatLib": { 07 "git-bare": { 08 "url": "git://github.com/Bob/GreatLib.git", 09 "version": "1.0.0" 10 } 11 } 12 }, 13 "require": { 14 "Twig": ">=1.0.0", 15 "AwesomeLib": "latest", 16 "GreatLib": "1.0.0", 17 "Monolog": "latest" 18 } 19 }Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  40. 40. Demo, kind of. (blame @naderman :)Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  41. 41. Fear code re-use no more.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  42. 42. Last wordsJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  43. 43. Namespace adoption, in effect, opens up a world of possibilities.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  44. 44. Open up your mind, were not alone.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  45. 45. Share your code and collaborate.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  46. 46. Thank you.Jordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be
  47. 47. Feedback please on: http://joind.in/3489 Slides: http://slides.seld.be Contact me: @seldaek || jordi@nelm.ioJordi Boggiano Company http://nelm.iohttp://twitter.com/seldaek Blog http://seld.be

×