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.

017c763fcb151eb13747f4983658c7ac?s=128

Daniel Holmes

July 22, 2012
Tweet

Transcript

  1. Today's Thriving PHP Ecosystem A community discussion with Kansas City's

    PHP User Group July 21, 2011 @dan_holmes
  2. We all know what PHP looks like

  3. This is PHP

  4. And this is PHP

  5. And THIS is PHP phpBB phpExcel CakePHP CodeIgnighter FuelPHP Silex

    Symfony Zend Framework Doctrine all logos are Trademarked by their respective owners
  6. PHP is So Much More

  7. This is PHP and MongoDB

  8. This is PHP and XML/XPATH

  9. This is PHP and Closures

  10. This is PHP and Tonic w/Annotations

  11. Not just stand-alone web-apps Fact is, PHP is used for

    all kinds of development
  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
  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
  14. and for good reasons PHP is very Popular

  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
  16. Great Hosting Options Cloud / Shared / Dedicated Platform as

    a Service all logos are Trademarked by their respective owners
  17. Server Architectures • Apache / mod_php • Apache / fastcgi

    PHP • Nginx / Apache / mod_php + APC • Nginx / PHP-FPM + APC • Nginx / PHP-FPM + APC + Memcached
  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!
  19. When you want to carry your own cloud of servers

    with you everywhere VirtualBox
  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/
  21. Ok, Let's get back to PHP

  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
  23. The Friendly and Versatile Platypus Source: SnorgTees http://www.snorgtees.com/our-powers-combined

  24. None
  25. None
  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
  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
  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!
  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!
  30. PHP Fun you may have missed DateTime class ◦ replaces/improves

    on mktime(), strtotime(), date()...
  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"
  32. Interactive Shell! No, I am not kidding. It's been in

    there for a while now
  33. Just like a bash shell. But it's PHP. In a

    shell. Interactively. Tab Tab.... oooh!
  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.
  35. But, C'mon! Totally worth it! Really, I'm worth it!

  36. ONLY For development! SRSLYTHO No Apache needed There is also

    a Web Server built into 5.4
  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
  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
  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
  40. Just real quick....C'mon, there's good stuff in there. PECL

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

    each every category.
  42. QA Tools Seeking Higher Quality, Craftsmanship, Repeatability

  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.
  44. PHPUnit - Silex Framework Support Silex and Symfony add services

    to help you check your content
  45. PHPUnit - ZF1 Framework Support Zend Framework 1 takes a

    different approach by Extending PHPUnit Yep. That's assert by CSS Selector. :-)
  46. PHPUnit Extensions Selenium Server Test using actual browser engines

  47. PHPUnit Extensions Selenium Server Test using actual browser engines

  48. phpqatools.org The PHP Quality Assurance Toolchain

  49. phpqatools.org

  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
  51. Travis-ci.org Are you in github? Is your project public? Use

    more than one language?
  52. Systems Integration Tools Phing! Used to automate • Packaging •

    Deploying • Testing • Anything! Like Ant, but you write your tasks in PHP / XML!
  53. You no longer have to code alone Packages and Dependencies

  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
  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
  56. all logos are Trademarked by their respective owners

  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
  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
  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
  60. Using Packagist Finding packages is as easy as typing keywords

    Click in to see who all is on it, what it provides, etc
  61. Often, Core PHP alone isn't enough e.g. That second time

    you copy-paste something
  62. We like our frameworks. We must...we have so many! Cake

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

    on FuelPHP: http://fuelphp.com
  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/
  65. We like our frameworks. We must...we have so many! More

    on Zend Framework: http://framework.zend.com
  66. REST API Builders Micro Framework

  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
  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/
  69. Getting Started in PHP?

  70. PHP is all about Solving Problems

  71. What do you do? You need to show data from

    a database on a web page
  72. You Google It!

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

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

  75. Well, what about php.net?

  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*
  77. Well, there's PDO. If I make it to read it.

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

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

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

    one Query The Truth is...
  81. This problem is EVERYWHERE And unless you KNOW PHP, you

    may miss that it is even there
  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!
  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..
  84. None
  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
  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
  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
  88. None
  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
  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
  91. Thank you! daniel.holmes@gmail.com | @dan_holmes http://mojolive.com/profile/dan For Kansas City's PHP

    User Group http://kcpug.org