php framework “battle”
DESCRIPTION
PHP Framework “Battle”. Zakir Hemraj. Slides and code will be posted on the meetup group Video will be posted on: achievers.com/tech Tell your friends!. About Me. Dev Team Lead @ Achievers Professional Web Framework Experience: J2EE with Spring, Hibernate PHP with CodeIgniter - PowerPoint PPT PresentationTRANSCRIPT
PHP Framework “Battle”
Zakir Hemraj
• Slides and code will be posted on the meetup group
• Video will be posted on: achievers.com/tech
• Tell your friends!
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 or Symfony
Goal
1. Give you “flavor” of a few frameworks
2. Share some scientific and subjective comparisons
3. Make you better equipped to compare and choose the right framework
What I’m not doing…
• In-depth framework code walkthrough of all features and functions
• Handing you a silver bullet
Agenda
1. Overview of frameworks 2. Review basic concepts– MVC, ORMs
3. The application – requirements, db schema
4. Code walkthrough5. Performance and other comparisons6. Final thoughts
The Contenders
Big Sites
CakePHP Zend Framework Symfony CodeIgniter
askmen.com legaldownload.net cfl.ca dictionary.com
usafootball.com onewishlist.net flash-wars.com codeguru.com
gamestous.com manageme.in ted.com expressionengine.com
Sources: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
“You can write shitty code in any language, any framework”
Review - MVC
Source: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
• Most web frameworks are MVC these days
• Lots of inconsistencies with the “model” layer
HTTP Request
HTML
Business Logic & DB Access
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 programming
class TechTalk{ }
table:tech_talk
ORM
Now What?
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 your sleep
The Schema
Setup1. Download
framework *
2. Configure your app with your db
3. Point your web server to the directory (i.e. vhost in apache)
4. Start coding
Zend Code Summary
• Nice command line tools -> less typing
• Hard object instantiations play nice with IDE
• Good, OO separation of layers, including db access, business logic, and forms
• Cons: We’ll discuss later ;)
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
CAKE Summary
• Rails-like convention over configuration
• Very powerful, with convenient tools like scaffolding and strong relational mapping
• Lots of “magic” that you need to be aware of
CON
FIGU
RATI
ON
CONVENTION
CI CAKEZend
Documentation
• Zend: – Complete, but fragmented – hard to follow.
• CI – Great
• CAKE– Outstanding
Other ComparisonsZend CI CAKE
i18n Y Y Y
unit testing Y N * Y
templating Y Y * Y
security utils Y Y Y
authentication Y N Y
caching Y Y Y
Performance
• Source: http://www.ruilog.com/blog/view/b6f0e42cf705.html
• Simple MVC logic, no DB connection
• See site for full hardware specs
Requests per Second
CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.60
500
1000
1500
2000
25002331
873
678
1367
Memory Usage (KB)
CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.60
500
1000
1500
2000
2500
3000
752.55
2824.26
2576.47
1711.57
System Load Average in 1 Minute
CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.60
2
4
6
8
10
12
1.65
5.1
10.02
1.44
Avg. Response Time (Milliseconds)
CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.60
5
10
15
20
25
7.24
14.73
20.22
12.79
Number of Function Calls
CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.60
200
400
600
800
1000
1200
1400
1600
1800
2000
491
834
1789
792
Number of Included Files
CodeIgniter 2.1 CakePHP 2.0.4 Zend 1.11.11 Symfony 2.0.60
10
20
30
40
50
60
70
AND LASTLY…
My Two Cents
• Too much abstraction is bad
• Understand the tradeoffs
• You will need to break out of the framework
• Stay curious
<?echo “END”;die();
?>