SlideShare uma empresa Scribd logo
1 de 47
Baixar para ler offline
PHP Reset
                         Jordi Boggiano @seldaek
                              http://nelm.io/

Jordi Boggiano                                     Company http://nelm.io
http://twitter.com/seldaek                             Blog http://seld.be
Disclaimer
                             This is not about REST




Jordi Boggiano                                        Company http://nelm.io
http://twitter.com/seldaek                                Blog http://seld.be
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
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
A bit of history




Jordi Boggiano                                  Company http://nelm.io
http://twitter.com/seldaek                          Blog http://seld.be
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
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
Could you spot the differences?




Jordi Boggiano                              Company http://nelm.io
http://twitter.com/seldaek                      Blog http://seld.be
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
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
Again, not much has changed.
                   But it changes everything.
                             BackslashMeansNoBackwardsCompatibility




Jordi Boggiano                                                            Company http://nelm.io
http://twitter.com/seldaek                                                    Blog http://seld.be
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
New Frameworks




Jordi Boggiano                                Company http://nelm.io
http://twitter.com/seldaek                        Blog http://seld.be
Symfony2
                              Lithium
                               Silex
                                ZF2
                                 ...
                                  .


Jordi Boggiano                          Company http://nelm.io
http://twitter.com/seldaek                  Blog http://seld.be
New Libraries




Jordi Boggiano                               Company http://nelm.io
http://twitter.com/seldaek                       Blog http://seld.be
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
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
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
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
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
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
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
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
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
I can't list them all.




Jordi Boggiano                                        Company http://nelm.io
http://twitter.com/seldaek                                Blog http://seld.be
GitHub




Jordi Boggiano                        Company http://nelm.io
http://twitter.com/seldaek                Blog http://seld.be
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
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
Best Practices




Jordi Boggiano                                Company http://nelm.io
http://twitter.com/seldaek                        Blog http://seld.be
MIT License
               Free as in free.




Jordi Boggiano                                  Company http://nelm.io
http://twitter.com/seldaek                          Blog http://seld.be
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
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
Remember, kids, standards
                               are NOT about taste




Jordi Boggiano                                           Company http://nelm.io
http://twitter.com/seldaek                                   Blog http://seld.be
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
Composer




Jordi Boggiano                          Company http://nelm.io
http://twitter.com/seldaek                  Blog http://seld.be
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
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
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.io
http://twitter.com/seldaek                                                          Blog http://seld.be
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.io
http://twitter.com/seldaek                                                                 Blog http://seld.be
Demo, kind of.
                             (blame @naderman :)




Jordi Boggiano                                     Company http://nelm.io
http://twitter.com/seldaek                             Blog http://seld.be
Fear code re-use no more.




Jordi Boggiano                                       Company http://nelm.io
http://twitter.com/seldaek                               Blog http://seld.be
Last words




Jordi Boggiano                            Company http://nelm.io
http://twitter.com/seldaek                    Blog http://seld.be
Namespace adoption, in effect,
                     opens up a world of
                        possibilities.




Jordi Boggiano                               Company http://nelm.io
http://twitter.com/seldaek                       Blog http://seld.be
Open up your mind,
                              we're not alone.




Jordi Boggiano                                    Company http://nelm.io
http://twitter.com/seldaek                            Blog http://seld.be
Share your code
                             and collaborate.




Jordi Boggiano                                  Company http://nelm.io
http://twitter.com/seldaek                          Blog http://seld.be
Thank you.




Jordi Boggiano                            Company http://nelm.io
http://twitter.com/seldaek                    Blog http://seld.be
Feedback please on:
                         http://joind.in/3489
                                Slides:
                         http://slides.seld.be
                             Contact me:
                       @seldaek || jordi@nelm.io


Jordi Boggiano                                 Company http://nelm.io
http://twitter.com/seldaek                         Blog http://seld.be

Mais conteúdo relacionado

Semelhante a PHP Reset

Make Your Own Charting Library with d3
Make Your Own Charting Library with d3Make Your Own Charting Library with d3
Make Your Own Charting Library with d3
yieldbot
 

Semelhante a PHP Reset (20)

Social coding をもっと楽しみたいあなたへ
Social coding をもっと楽しみたいあなたへSocial coding をもっと楽しみたいあなたへ
Social coding をもっと楽しみたいあなたへ
 
Design of a BIOLOID Scorpion Report
Design of a BIOLOID Scorpion ReportDesign of a BIOLOID Scorpion Report
Design of a BIOLOID Scorpion Report
 
Jabber Bot
Jabber BotJabber Bot
Jabber Bot
 
Tales from the OSGi trenches
Tales from the OSGi trenchesTales from the OSGi trenches
Tales from the OSGi trenches
 
Building and deploying Cocoa applications with ChocTop
Building and deploying Cocoa applications with ChocTopBuilding and deploying Cocoa applications with ChocTop
Building and deploying Cocoa applications with ChocTop
 
Zero To Dojo
Zero To DojoZero To Dojo
Zero To Dojo
 
LeapMotion for Web with React and Flux
LeapMotion for Web with React and FluxLeapMotion for Web with React and Flux
LeapMotion for Web with React and Flux
 
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...
 
Ultrabootstrapping: Launching a Startup for Less Than $1000
Ultrabootstrapping: Launching a Startup for Less Than $1000Ultrabootstrapping: Launching a Startup for Less Than $1000
Ultrabootstrapping: Launching a Startup for Less Than $1000
 
Dojo: Getting Started Today
Dojo: Getting Started TodayDojo: Getting Started Today
Dojo: Getting Started Today
 
Dojo tutorial
Dojo tutorialDojo tutorial
Dojo tutorial
 
20150317 firefox os_studymtg_engver
20150317 firefox os_studymtg_engver20150317 firefox os_studymtg_engver
20150317 firefox os_studymtg_engver
 
Tales from the OSGi Trenches - Bertrand Delacretaz
Tales from the OSGi Trenches - Bertrand DelacretazTales from the OSGi Trenches - Bertrand Delacretaz
Tales from the OSGi Trenches - Bertrand Delacretaz
 
Gerrit Code Review with GitHub plugin
Gerrit Code Review with GitHub pluginGerrit Code Review with GitHub plugin
Gerrit Code Review with GitHub plugin
 
JavaScript Power Tools
JavaScript Power ToolsJavaScript Power Tools
JavaScript Power Tools
 
Pyramid and the Pylons Project in the wild
Pyramid and the Pylons Project in the wildPyramid and the Pylons Project in the wild
Pyramid and the Pylons Project in the wild
 
Encode polkadot club
Encode polkadot club  Encode polkadot club
Encode polkadot club
 
Make Your Own Charting Library with d3
Make Your Own Charting Library with d3Make Your Own Charting Library with d3
Make Your Own Charting Library with d3
 
Release management with NuGet/Chocolatey/JIRA
Release management with NuGet/Chocolatey/JIRARelease management with NuGet/Chocolatey/JIRA
Release management with NuGet/Chocolatey/JIRA
 
Patterns and antipatterns in Docker image lifecycle @ Codemash 2017
Patterns and antipatterns in Docker image lifecycle @ Codemash 2017Patterns and antipatterns in Docker image lifecycle @ Codemash 2017
Patterns and antipatterns in Docker image lifecycle @ Codemash 2017
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

PHP Reset

  • 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
  • 13. New Frameworks Jordi Boggiano Company http://nelm.io http://twitter.com/seldaek Blog http://seld.be
  • 14. Symfony2 Lithium Silex ZF2 ... . Jordi Boggiano Company http://nelm.io http://twitter.com/seldaek Blog http://seld.be
  • 15. New Libraries 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
  • 29. Best Practices 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
  • 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.io http://twitter.com/seldaek Blog http://seld.be
  • 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.io http://twitter.com/seldaek Blog http://seld.be
  • 40. Demo, kind of. (blame @naderman :) Jordi Boggiano Company http://nelm.io http://twitter.com/seldaek Blog http://seld.be
  • 41. Fear code re-use no more. Jordi Boggiano Company http://nelm.io http://twitter.com/seldaek Blog http://seld.be
  • 42. Last words 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
  • 46. Thank you. Jordi Boggiano Company http://nelm.io http://twitter.com/seldaek Blog http://seld.be
  • 47. Feedback please on: http://joind.in/3489 Slides: http://slides.seld.be Contact me: @seldaek || jordi@nelm.io Jordi Boggiano Company http://nelm.io http://twitter.com/seldaek Blog http://seld.be