PHP Framework Battle

  • 7,173 views
Uploaded 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, …

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.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
7,173
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    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

Transcript

  • 1. PHP Framework “Battle”Zakir Hemraj
  • 2. • Slides and code willbe posted on themeetup group• Video will be postedon:achievers.com/tech• Tell your friends!
  • 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. Goal1. Give you “flavor” of a few frameworks2. Share some scientific and subjectivecomparisons3. Make you better equipped to compare andchoose the right framework
  • 5. What I’m not doing…• In-depth framework code walkthrough of allfeatures and functions• Handing you a silver bullet
  • 6. Agenda1. Overview of frameworks2. Review basic concepts– MVC, ORMs3. The application– requirements, db schema4. Code walkthrough5. Performance and other comparisons6. Final thoughts
  • 7. The Contenders
  • 8. Big SitesCakePHP Zend Framework Symfony CodeIgniteraskmen.com legaldownload.net cfl.ca dictionary.comusafootball.com onewishlist.net flash-wars.com codeguru.comgamestous.com manageme.in ted.com expressionengine.comSources:http://book.cakephp.org/1.2/view/510/Sites-in-the-wildhttp://framework.zend.com/wiki/pages/viewpage.action?pageId=14134http://trac.symfony-project.org/wiki/ApplicationsDevelopedWithSymfony
  • 9. “You can write shitty code in anylanguage, any framework”
  • 10. Review - MVCSource: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller• Most web frameworksare MVC these days• Lots of inconsistencieswith the “model” layerHTTP RequestHTMLBusiness Logic& DB Access
  • 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. Now What?
  • 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. The Schema
  • 15. Setup1. Downloadframework *2. Configure your appwith your db3. Point your webserver to thedirectory (i.e. vhostin apache)4. Start coding
  • 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. 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. 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
  • 19. CONFIGURATIONCONVENTIONCI CAKEZend
  • 20. Documentation• Zend:– Complete, but fragmented– hard to follow.• CI– Great• CAKE– Outstanding
  • 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. Performance• Source:http://www.ruilog.com/blog/view/b6f0e42cf705.html• Simple MVC logic, no DB connection• See site for full hardware specs
  • 23. Requests per Second2331873678136705001000150020002500CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
  • 24. Memory Usage (KB)752.552824.262576.471711.57050010001500200025003000CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
  • 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. Avg. Response Time (Milliseconds)7.2414.7320.2212.790510152025CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
  • 27. Number of Function Calls49183417897920200400600800100012001400160018002000CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
  • 28. Number of Included Files010203040506070CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.6
  • 29. AND LASTLY…
  • 30. My Two Cents• Too much abstraction is bad• Understand the tradeoffs• You will need to break out of the framework• Stay curious
  • 31. <?echo “END”;die();?>