PHP Framework Battle


Published on

In this talk we explore the pros and cons of some of the most popular PHP frameworks by comparing the code required to build the exact same application. The frameworks cover in this talks are: Zend, CakePHP, CodeIgniter and Symfonyby.

Published in: Technology
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • -PHP Developers? -Experience with Zend, Cake, CodeIgniter, RoR, J2EE frameworks?-Had to choose a web framework for your company
  • Choosing a web frameworkis a lot like this. Claims to be:More enjoyable to useBetter securityBetter layers of separation
  • ZendRun by Zend technologiesCakeStarted in 2005Modeled on RoRIn 2009, some members left to start the Lithium framework
  • All frameworks “work” and have their benefitsThe reality is that
  • Poll audience -> what things do you look for
  • MySQLUsually would use singular labels for table nameInts, varchars, and datetime
  • Zend topics to cover:Zend command line utilities (zf)zf create project jobs_zendModel layerDifference between model and db_tablezf create model xzf create db-table job jobs (or create test)db tabledb table objects have built in functions and are 1-to-1 to tables (but not necessarily an orm). Simple DAOs. Override variables that define table, primary, and other options.Can write custom “queries” in db table objectsModelsMeant to encapsulate business logicDon’t extend anythingStrong object declaration makes for good IDE experienceIntroduce skinny controller, fat model ControllerIndex Contoller is defaultNaming conventions -> xAction, and url patterns -> not that cleanViewsBasic manipulation of dataSide notes:-good separation of staging, production, etc. out of the box
  • Go to wikipedia framework comparisons if you want more
  • AbstractionJavascript and html abstraction can lead to problems, working around framework to get what you wantQuery abstraction from ORM should be used with cautionTradeoffsRAD frameworks with lots of magic have their benefits, but also abstract devs from underlying performance issuesLite frameworks offer great performance, but you need to develop your own standards, especially for your own teamsBreakout-For almost any serious application, you’ll need to change or modify something about the framework-At Achievers, we needed to modify CI routing, logging, application loading, security filtering, etc. Understand the extendability of your applicationStay curiousLook under the covers always, and don’t be scaredUnderstand what’s happening behind the scenesUltimately, it’s the developer, not the framework
  • PHP Framework Battle

    1. 1. PHP Framework “Battle”Zakir Hemraj
    2. 2. • Slides and code willbe posted on themeetup group• Video will be• Tell your friends!
    3. 3. About Me• Dev Team Lead @ Achievers• Professional Web Framework Experience:– J2EE with Spring, Hibernate– PHP with CodeIgniter– Ruby on Rails• Not an expert in Zend Framework, CakePHP orSymfony
    4. 4. Goal1. Give you “flavor” of a few frameworks2. Share some scientific and subjectivecomparisons3. Make you better equipped to compare andchoose the right framework
    5. 5. What I’m not doing…• In-depth framework code walkthrough of allfeatures and functions• Handing you a silver bullet
    6. 6. Agenda1. Overview of frameworks2. Review basic concepts– MVC, ORMs3. The application– requirements, db schema4. Code walkthrough5. Performance and other comparisons6. Final thoughts
    7. 7. The Contenders
    8. 8. Big SitesCakePHP Zend Framework Symfony expressionengine.comSources:
    9. 9. “You can write shitty code in anylanguage, any framework”
    10. 10. Review - MVCSource:• Most web frameworksare MVC these days• Lots of inconsistencieswith the “model” layerHTTP RequestHTMLBusiness Logic& DB Access
    11. 11. Review - ORM• Object Relational Mapping• Maps database records to objects• 1-to-1 table to object class– E.g. job table -> job class• Layer of abstraction to:– Make code more maintainable– Enable stronger OO programmingclass TechTalk{ }table:tech_talkORM
    12. 12. Now What?
    13. 13. The Application• A basic job board where people can:– Add jobs– View a listing of jobs– Look at a post in more detail• So simple, you could probably code it in yoursleep
    14. 14. The Schema
    15. 15. Setup1. Downloadframework *2. Configure your appwith your db3. Point your webserver to thedirectory (i.e. vhostin apache)4. Start coding
    16. 16. Zend Code Summary• Nice command line tools -> less typing• Hard object instantiations play nice with IDE• Good, OO separation of layers, including dbaccess, business logic, and forms• Cons: We’ll discuss later ;)
    17. 17. CI Code Summary• Super lightweight• Very few conventions or “magic”– Doesn’t force things on you– Very explicit• Lots of well documented tools and libraries
    18. 18. CAKE Summary• Rails-like convention over configuration• Very powerful, with convenient tools likescaffolding and strong relational mapping• Lots of “magic” that you need to be aware of
    20. 20. Documentation• Zend:– Complete, but fragmented– hard to follow.• CI– Great• CAKE– Outstanding
    21. 21. Other ComparisonsZend CI CAKEi18n Y Y Yunit testing Y N * Ytemplating Y Y * Ysecurity utils Y Y Yauthentication Y N Ycaching Y Y Y
    22. 22. Performance• Source:• Simple MVC logic, no DB connection• See site for full hardware specs
    23. 23. Requests per Second2331873678136705001000150020002500CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
    24. 24. Memory Usage (KB)752.552824.262576.471711.57050010001500200025003000CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
    25. 25. System Load Average in 1 Minute1.655.110.021.44024681012CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
    26. 26. Avg. Response Time (Milliseconds)7.2414.7320.2212.790510152025CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
    27. 27. Number of Function Calls49183417897920200400600800100012001400160018002000CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
    28. 28. Number of Included Files010203040506070CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
    29. 29. AND LASTLY…
    30. 30. My Two Cents• Too much abstraction is bad• Understand the tradeoffs• You will need to break out of the framework• Stay curious
    31. 31. <?echo “END”;die();?>