Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Today's Thriving PHP Developer Ecosystem

Today's Thriving PHP Developer Ecosystem

Most people who actively work with PHP every day rarely confine themselves to just PHP.

PHP Developers have access to a nearly dizzying array of tools, packages, language features, QA tools and countless frameworks and styles to develop with. In this Tour of the PHP Ecosystem, long time PHP enthusiast Dan Holmes will attempt to highlight many of the projects and developments that have come of age in recent years.

Whether you have long settled on one particular style or framework for development, or just looking at PHP for the first time, we are sure you will spot something fresh you hadn't seen before.

Presented to the PHP User Group of Kansas City.

Daniel Holmes

July 22, 2012
Tweet

More Decks by Daniel Holmes

Other Decks in Programming

Transcript

  1. Today's Thriving PHP
    Ecosystem
    A community discussion with Kansas City's
    PHP User Group
    July 21, 2011
    @dan_holmes

    View Slide

  2. We all know what PHP
    looks like

    View Slide

  3. This is PHP

    View Slide

  4. And this is PHP

    View Slide

  5. And THIS is PHP
    phpBB
    phpExcel
    CakePHP
    CodeIgnighter
    FuelPHP
    Silex
    Symfony
    Zend Framework
    Doctrine
    all logos are Trademarked by their respective owners

    View Slide

  6. PHP is So Much More

    View Slide

  7. This is PHP and MongoDB

    View Slide

  8. This is PHP and XML/XPATH

    View Slide

  9. This is PHP and Closures

    View Slide

  10. This is PHP and Tonic
    w/Annotations

    View Slide

  11. Not just stand-alone web-apps
    Fact is, PHP is used for
    all kinds of development

    View Slide

  12. PHP's Many Uses:
    Who in here has...
    ● Added simple data or dates to a web page
    ● Extended a CMS like WordPress or Drupal ?
    ● Extended other packaged systems
    ○ Shopping Carts
    ○ Photo Galleries
    ● Automation / Backend Scripting
    ○ VAST collection of interfaces to c libraries make a
    very powerful tool
    ○ XML Parsing - Even XSL / XPAT
    ○ Image Processing with GD / ImageMagic
    ○ Integration with CURL

    View Slide

  13. PHP's Many Uses:
    Who in here is using PHP for...
    ● Creating Stand Alone Web-Applciations
    ● Writing Facebook Applications
    ● Writing Facebook
    ● REST / SOAP / RPC API Development

    View Slide

  14. and for good reasons
    PHP is very Popular

    View Slide

  15. Why PHP is still so popular
    ● Massive and Excellent Community
    ● Ultra-low barriers to entry
    ● Scales along
    with the developer
    ● Integrate, Interop or Glue Almost Anything!
    ● Runs on almost anything and anywhere
    all logos are Trademarked by their respective owners

    View Slide

  16. Great Hosting Options
    Cloud / Shared / Dedicated Platform as a Service
    all logos are Trademarked by their respective owners

    View Slide

  17. Server Architectures
    ● Apache / mod_php
    ● Apache / fastcgi PHP
    ● Nginx / Apache / mod_php + APC
    ● Nginx / PHP-FPM + APC
    ● Nginx / PHP-FPM + APC + Memcached

    View Slide

  18. No Server? No Problem!
    Two single-step install options for
    Linux/Mac/Win
    Zend Server Community Edition
    XAMPP
    Includes PHP, Apache, MySQL and Extras!

    View Slide

  19. When you want to carry your own cloud of
    servers with you everywhere
    VirtualBox

    View Slide

  20. Just a few Tools to Edit your PHP
    Many More at http://en.wikipedia.org/wiki/List_of_PHP_editors
    Text Editors
    ● Textmate 2
    ● Sublime Text 2
    ● Notepad ++
    ● VIM! w/wo Lots of
    plugins
    And no, not emacs. We won. Move on. ;-)
    IDE's (Yes, with run-time debugging /
    profiling)
    ● PHP Storm
    ● Netbeans
    ● Zend Studio /
    Eclipse PDT
    http://coding.smashingmagazine.com/2009/02/11/the-big-
    php-ides-test-why-use-oneand-which-to-choose/

    View Slide

  21. Ok, Let's get back to PHP

    View Slide

  22. ● Has been evolving for over 17 years
    ● New versions rarely break compatibility
    ● Backed / influenced by hundreds of C libs
    ● SSI, Procedural, Object-Oriented, Reflective
    ● Grown to support TDD, BDD, CI, DI, etc ;-)
    The Friendly and Versatile Platypus

    View Slide

  23. The Friendly and Versatile Platypus
    Source: SnorgTees http://www.snorgtees.com/our-powers-combined

    View Slide

  24. View Slide

  25. View Slide

  26. These last three shots were from Thijs Lensselink's site: http://lenss.nl/tag/elephpant/
    Go buy one of these little blue (or pink) creatures at http://elephpant.com/ ~$12 bucks

    View Slide

  27. PHP: Always getting new powers
    ● [5.0] Classes, Interfaces, Abstracts, Privates,
    Type Hinting with Class Names
    ● [5.1] PDO Included by default
    ● [5.2] Filter Validation, JSON support
    Just as a reminder, 5.0 came out in July, 2004. 5.2 in 2006

    View Slide

  28. PHP: Always getting new powers - 5.3
    (2009)
    ● Namespaces
    ● Late Static Bindings
    ● Closures
    ● Nested Exceptions
    PCRE, Reflection and SPL are now ALWAYS
    available! "They" can't Build PHP w/o them!

    View Slide

  29. PHP: Always getting new powers - 5.4 (Mar)
    ● Traits
    ● session.upload_progress.enabled
    ● = is always available, from now on
    ● register_globals not just deprecated--GONE!

    View Slide

  30. PHP Fun you may have missed
    DateTime class
    ○ replaces/improves on mktime(), strtotime(), date()...

    View Slide

  31. PHP Fun you may have missed
    ● Phar
    ● SPL - the Standard PHP Library
    ○ RegexIterator class
    ○ 13 Standard Exceptions including:
    OutOfBounds, BadMethodCall, InvalidArgument...
    ○ Baseclasses and Interfaces for Iterators, Observers,
    Heaps, Queues, Stacks and Arrays
    ○ All with an Object-Oriented interface
    ○ Many with an optional function "front-end"

    View Slide

  32. Interactive Shell!
    No, I am not kidding.
    It's been in there for a while now

    View Slide

  33. Just like a bash shell.
    But it's PHP. In a shell. Interactively.
    Tab Tab....
    oooh!

    View Slide

  34. There is a trick though. If it says "Interactive mode enabled"
    That's not the same thing (as you can see above)
    You need to compile php --with-readline support.

    View Slide

  35. But, C'mon! Totally worth it!
    Really,
    I'm worth it!

    View Slide

  36. ONLY For development!
    SRSLYTHO No Apache needed
    There is also a
    Web Server
    built into 5.4

    View Slide

  37. Tell me what these things do:
    ● echo $foo ?: "x" ;
    ● $a =[1,2,3,4];
    ● $b = ['apple'=>['color'=>'green']];
    ● $tag->getStyles()['font-size']->embiggen();
    Syntactic Sugar Or, examples of things
    language designers do to
    try and get legitimate
    discussions moving again

    View Slide

  38. True Power in Knowledge...
    And PHP Knows how to do a lot
    If you haven't REALLY looked at the
    PHP documentation lately
    you should.
    If you don't know where to start, at least get a
    feel for the kinds of things it can do
    http://www.php.net/manual/en/extensions.membership.php

    View Slide

  39. Let's take Databases for example
    PHP Data Objects (PDO)
    ● CUBRID
    ● Firebird/Interbase
    ● IBM DB2
    ● Informix
    ● MS SQL Server
    ● MySQL
    ● Oracle
    ● PostgreSQL
    ● 4D
    Direct Driver access
    over 23 drivers from
    MongoDB to Paradox
    and dBase.
    PECL / Vendor Extensions
    ● Couchbase
    ● Solr
    ● Sphinx

    View Slide

  40. Just real quick....C'mon,
    there's good stuff in there.
    PECL

    View Slide

  41. That's enough about PECL.
    But, probably an interesting talk
    under each every category.

    View Slide

  42. QA Tools
    Seeking Higher
    Quality, Craftsmanship, Repeatability

    View Slide

  43. Unit Testing
    phpt
    Used mainly for core php
    PHPUnit
    Very popular, modular unit testing platform
    There is also SimpleTest, and others. These two just contrast very well.

    View Slide

  44. PHPUnit - Silex Framework Support
    Silex and Symfony add services to help you
    check your content

    View Slide

  45. PHPUnit - ZF1 Framework Support
    Zend
    Framework 1
    takes a
    different
    approach by
    Extending
    PHPUnit Yep. That's
    assert by CSS
    Selector. :-)

    View Slide

  46. PHPUnit Extensions
    Selenium Server
    Test using actual browser engines

    View Slide

  47. PHPUnit Extensions
    Selenium Server
    Test using actual browser engines

    View Slide

  48. phpqatools.org
    The PHP Quality Assurance Toolchain

    View Slide

  49. phpqatools.org

    View Slide

  50. Jenkins PHP / Continuous
    Integration Server
    ● Written in Java
    ● Integrates with your VCS repositories
    ● Can run a variety of Tests and reports
    ● Keeps things "clean"
    ● PHP_CodeSniffer, PHPMD, phpDox

    View Slide

  51. Travis-ci.org
    Are you in github?
    Is your project
    public?
    Use more than
    one language?

    View Slide

  52. Systems Integration Tools
    Phing!
    Used to automate
    ● Packaging
    ● Deploying
    ● Testing
    ● Anything!
    Like Ant, but you write your tasks in PHP /
    XML!

    View Slide

  53. You no longer have to code alone
    Packages and
    Dependencies

    View Slide

  54. PEAR - Reusable PHP Components
    ● First big package repo - PEAR 1.0 was 2003
    ● Can download, install, update packages
    ● Manages channels of packages
    ● Still VERY important / useful packages
    ● CLI Interface

    View Slide

  55. PEAR - Reusable PHP Components
    ● Mail_Mime, Image_QRcode, Image_Canvas
    ● Archive_Tar, Image_Transform
    ● Services_W3C_CSSValidator
    ● Payment Systems, Web Systems,
    Birtorrent2
    ● Almost 8.5 million lines of code

    View Slide

  56. all logos are Trademarked by their respective owners

    View Slide

  57. Composer
    ● VERY New, but exploding in popularity
    ● Very similar to node’s npm or ruby’s bundler
    ● CLI based
    ● Dependencies defined per project
    ● Easily lock to a version, install dependencies
    ● Tasks like creating a skeleton for your latest
    framework-based project

    View Slide

  58. Using Composer
    Install Composer
    Define monolog
    in your composer.
    json file
    Install Deps
    Create an
    unrelated project
    $ curl -s http://getcomposer.org/installer | php
    $ vim /my/project/composer.json
    {
    "require": {
    "monolog/monolog": "1.0.*"
    }
    }
    $ alias composer="php composer.phar"
    $ composer install
    $ composer create-project doctrine/orm path
    2.2.0

    View Slide

  59. Composer Packages live in a VCS
    " Packagist is the main package repository for composer,
    and it is enabled by default. Anything that is published on
    packagist is available automatically through composer. "
    - http://getcomposer.org

    View Slide

  60. Using Packagist
    Finding packages is
    as easy as typing
    keywords
    Click in to see who all
    is on it, what it
    provides, etc

    View Slide

  61. Often, Core PHP alone
    isn't enough
    e.g. That second time
    you copy-paste something

    View Slide

  62. We like our frameworks.
    We must...we have so many!
    Cake is:
    ● MVC
    ● Convention Driven
    ● Rapid Development
    Learn More at:
    http://cakephp.org

    View Slide

  63. We like our frameworks.
    We must...we have so many!
    More on FuelPHP: http://fuelphp.com

    View Slide

  64. We like our frameworks.
    We must...we have so many!
    Symfony is one of the
    leading first-class,
    large-scale
    frameworks of the
    PHP community.
    That Doesn't mean it
    isn't full of light agile
    tricks.
    Here, we see how it
    can use annotations
    to dynamically
    choose different
    views depending on
    the request URL
    More on Symfony: http://symfony.com/

    View Slide

  65. We like our frameworks.
    We must...we have so many!
    More on Zend Framework: http://framework.zend.com

    View Slide

  66. REST API Builders
    Micro Framework

    View Slide

  67. Micro Frameworks
    Taken from examples at: http://www.slimframework.
    com/documentation/stable
    Micro Frameworks are:
    ● lean / fast
    ● Build with HTTP
    handling in mind
    ● Provides an
    excellent way to
    build REST APIs

    View Slide

  68. Micro Frameworks
    ● Silex is a little
    different
    ● Still "micro" but is
    built on Symfony
    ● Great for HTTP
    Request APIs
    ● Stilll an excellent
    choice for traditional
    applications too
    ● Like Symfony2, Uses
    Twig for views
    Be sure to check out more about Silex at: http://silex.sensiolabs.org/

    View Slide

  69. Getting Started in PHP?

    View Slide

  70. PHP is all about
    Solving Problems

    View Slide

  71. What do you do?
    You need to show
    data from a database
    on a web page

    View Slide

  72. You
    Google
    It!

    View Slide

  73. Or, maybe you know about database
    abstraction layers...

    View Slide

  74. But,
    those
    are
    even
    older!
    2002?!

    View Slide

  75. Well, what about php.net?

    View Slide

  76. Just looking to query some data...
    1. Go to PHP.net
    2. Click on Documentation
    3. Click on English (presumably)
    4. Scroll down...down
    5. Database Security...woah!
    6. Scroll Down
    7. Persistent Database Connections...Nope.
    8. Ah! Database Extensions! *click*

    View Slide

  77. Well, there's PDO.
    If I make it to read
    it.

    View Slide

  78. PHP.net is the complete lexicon for PHP
    It's Developer Documentation
    The Truth is...

    View Slide

  79. You stopped looking long ago, and just
    followed a blog post.
    The Truth is...

    View Slide

  80. When embedding data into a webpage,
    It's never just the one Query
    The Truth is...

    View Slide

  81. This problem is
    EVERYWHERE
    And unless you KNOW PHP,
    you may miss that it is even there

    View Slide

  82. Lost in the land of blog posts
    PHP.net is one of the most complete language
    resources, anywhere.
    I love it.
    I learned with it.
    I grew with it.
    Sadly: task-oriented, poorly written blog posts
    from 2004 are easiest to find. Just Google It!

    View Slide

  83. Lost in the land of blog posts
    ● I want to keep growing, but where do I start?
    ● Where does a new developer start?
    ● What does "the right way" even look like?
    Ahh...ahh.
    I see what you
    did there..

    View Slide

  84. View Slide

  85. PHPTheRightWay.com
    Now, right off the bat they explain what they
    mean:
    There is no canonical way to use PHP.
    However, this website is a humble display of
    best practices, available options, and good
    information. It aims to introduce new PHP
    developers and to rethink seasoned pros with
    fresh ideas.
    - http://phptherightway.com

    View Slide

  86. PHPTheRightWay.com
    A living webpage ready to fork on github
    Topics include:
    ○ Getting Started
    (environnement, etc)
    ○ Code Style guide
    ○ Language Highlights
    ○ Dependency
    Management
    ○ Coding Practices
    ○ Databases
    ○ Security
    ○ Testing
    ○ Servers and
    Deployment
    ○ Caching
    ○ Resources
    ○ Frameworks
    ○ Community

    View Slide

  87. PHPTheRightWay.com
    This site is so very exciting to me personally
    DON'T get lost in the title
    DON'T feel bad if you learn something
    DO read the thing start to finish
    DO get inspired to do a talk on something good

    View Slide

  88. View Slide

  89. PHP Mentoring
    Building Strong Developers
    Mentors
    "Mentors are teachers
    and counselors and
    coaches and friends,
    but they are not
    perfect and aren't
    expected to be."
    Apprentices
    "Apprentices are
    students and team
    members and friends,
    but they are not
    perfect and aren't
    expected to be."
    - http://phpmentoring.org

    View Slide

  90. We are Just scratching the surface...
    Things we touched
    on:
    ● Many uses and
    powers of PHP
    ● Architecture
    ● Development Tools
    ● Language Features
    ● phpqatools.com
    ● PEAR & Composer
    ● (micro)
    Frameworks
    Things you will find in
    phptherightway.com
    ● More Detail, Links,
    Recommendations
    ● More Ideas
    ● Caching
    ● People to Follow
    ● More PaaS
    Providers

    View Slide

  91. Thank you!
    [email protected] | @dan_holmes
    http://mojolive.com/profile/dan
    For Kansas City's PHP User Group
    http://kcpug.org

    View Slide