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



Presented by William Estrada, leader of the OCPHP - @ocphp and OCDrupal meetup goups given at our Mini Language Fest meetup on 5/8/2013


  1. PHP SGV Designers and Developers Mini Language Festival (May 2013)

    william estrada linkedin.com/in/webbywe
  2. ABOUT ME PHP and Drupal Web Application Developer 5+ years

    Orange County PHP (OCPHP) Organizer : 7 years Orange County Drupal (OC Drupal) CoOrganizer : 2 years Grew up in San Gabriel Valley area (Azusa) Lives in Orange County
  3. ABOUT PRESENTATION A Brief History Very Quick Overview Basics Beyond

    Basics Leveraging the community Frameworks for your content Resources Questions PHP is pretty broad so not very technical

  5. PAST Rasmus Lerdorf conceived PHP in 1994 Personal Home Page

    Tools (PHP Tools) A simple parser to generate dynamic content through variables in HTML Zeev Suraski and Andi Gutmans from Tel Aviv get Involved Added thread safety mechanism and more advanced tag-parsing mechanism Known as the Zend Engine PHP 4.0 released in May 2000
  6. TODAY PHP 5.x is released Many development enhancements incorporated including

    OOP, XML, and Database connectivity Core developers continue to add features Zeev Suraski and Andi Gutmans formed Zend to target the Enterprise Zend Framework Zend Server Zend Studio

  8. BASICS Runs on apache nginx windows Connects with mysql mongodb

    postgres Tests with Simpletest PHPUnit Common Setups
  9. BASICS Mix PHP syntax with your HTML Good but ....

    separate your PHP, CSS, and XHTML in individual files <html> <head> <title>PHP Test</title> <style> p { color: red; } </style> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body> </html> Simple Example
  10. BASICS Separate code into files Manage your code


  12. BEYOND BASICS do OOP instead (if possible) If you do

    procedural function get_posts() { // Build database query $sql = 'select * from post'; // Execute query and return all rows return execute_query($sql); } OOP class blog { public function get(){ // Build database query $sql = 'select * from post'; // Execute query and return all rows return execute_query($sql); } }
  13. BEYOND BASICS Debugging Maintainability Readability of Code OOP Benefits Procedural

    can be quicker to crank out but OOP provides Many frameworks are heavy on OOP
  14. BEYOND BASICS What are they? Well-thought out solutions to programming

    problems Design Patterns Leverage Design Patterns in OOP code
  15. BEYOND BASICS Design Patterns : Decorator Pattern class HtmlEntitiesDecorator extends

    ServiceClientDecorator { public function getData() { return htmlentities($this->serviceClient- >getData()); } } abstract class ServiceClientDecorator implements ServiceClient { protected $serviceClient; public function __construct(ServiceClient $serviceClient) { $this->serviceClient = $serviceClient; } } $client = new MyWebServiceClient(); // Add our decorators $client = new HtmlEntititesDecorator($client); $client = new ParagraphDecorator($client); // Later in your code, and possibly in multiple places print $client->getData();
  16. BEYOND BASICS Many new frameworks use it (eg. Laravel) Easy

    way to include dependencies Composer A new Dependency Manager going forward
  17. BEYOND BASICS Ways Frameworks can work with one another Propose

    standards recommendations (PSR) Voting members from various top frameworks Standards PHP Framework Interoperability Group (PHP FIG)
  18. BEYOND BASICS PSR-0 Standards : Accepted Autloader interoperability How to

    structure qualified namespaces so framework can easily autoload classes PSR-1 Basic coding standards High level basics of coding standards to complement a frameworks own standard PSR-2 Basic coding style High level coding styles (formatting) that extends PS-1. PSR-3 Common library logging interface Allow libraries to receive a logging interface object and write the log in a simple and universal way

  20. DON’T REINVENT THE WHEEL leverage the community to get your

    content to the user
  21. FRAMEWORKS Zend Framework Enterprise Level Framework More involved framework /

    Heavy OOP Great documentation and examples Zend (the original PHP people) lead development Provides an MVC base structure (Custom applications)
  22. FRAMEWORKS CodeIgniter Easy to use Framework Great documentation Company leads

    direction with community involvement (also a negative) Many plugins available Provides an MVC base structure (Custom applications)
  23. FRAMEWORKS Symfony Easy to learn framework Decoupled (components can be

    used seperately, eg, use its serial component) Great documentation and examples Company and community lead development Provides an MVC base structure (Custom applications)
  24. FRAMEWORKS Laravel Easy to use framework Good documentation support A

    fairly new framework that takes advantage of PHP’s latest Company and community lead developer (currently hot in community) Provides an MVC base structure (Custom applications) Uses pieces of Symfony
  25. FRAMEWORKS Drupal Easy to use CMS (can also be used

    as Framework) Incredible community support Great documentation, examples, and countless modules Core (mostly from Acquia) and community leads its development Provides and out of the box CMS Upcoming Drupal 8 will use pieces of Symfony (other option, Wordpress)
  26. TEMPLATING Twig Popular template engine Good documentation and API Friendly

    syntax than designer having to know PHP Can be plugged into other Frameworks Will be used at the Drupal 8 template engine (other option, Smarty)
  27. WHY PHP?

  28. DEVELOPMENT Many hobbyist (easy syntax to learn - to a

    fault) Demand is very high Abundant developers 23,151,357 websites using PHP.
  29. WHY PHP Powers some top topic content websites Drupal Drupal

    Zend Framework

  31. Books RESOURCES Programming PHP 3rd Edition Teaches how to created

    effective applications in PHP 5.x Goes from basic to the advanced
  32. RESOURCES http://www.fluffycat.com/PHP-Design-Patterns/ http://php.net/ http://net.tutsplus.com/tutorials/php/object-oriented-php-for-beginners/ http://drupal.org/ http://framework.zend.com/ http://laravel.com/ http://symfony.com/ http://ellislab.com/codeigniter http://twig.sensiolabs.org/

    http://trends.builtwith.com/framework/PHP https://github.com/php-fig/fig-standards URLs https://gist.github.com/ziadoz/1677679#resources http://www.lynda.com/PHP-tutorials/php-with-mysql-essential-training/435-2.html

  34. WILLIAM ESTRADA Freelance PHP/Drupal Applications Developer linkedin.com/in/webbywe | william.estrada@webbywe.com @ocphp