php framework “battle”

36
PHP Framework “Battle” Zakir Hemraj

Upload: gzifa

Post on 24-Feb-2016

38 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: PHP Framework “Battle”

PHP Framework “Battle”

Zakir Hemraj

Page 2: PHP Framework “Battle”

• Slides and code will be posted on the meetup group

• Video will be posted on: achievers.com/tech

• Tell your friends!

Page 3: PHP Framework “Battle”

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

Page 4: PHP Framework “Battle”
Page 5: PHP Framework “Battle”
Page 6: PHP Framework “Battle”

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

Page 7: PHP Framework “Battle”

What I’m not doing…

• In-depth framework code walkthrough of all features and functions

• Handing you a silver bullet

Page 8: PHP Framework “Battle”

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

Page 9: PHP Framework “Battle”

The Contenders

Page 10: PHP Framework “Battle”

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

Page 11: PHP Framework “Battle”

“You can write shitty code in any language, any framework”

Page 12: PHP Framework “Battle”

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

Page 13: PHP Framework “Battle”

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

Page 14: PHP Framework “Battle”

Now What?

Page 15: PHP Framework “Battle”

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

Page 16: PHP Framework “Battle”

The Schema

Page 17: PHP Framework “Battle”

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

Page 18: PHP Framework “Battle”
Page 19: PHP Framework “Battle”

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 ;)

Page 20: PHP Framework “Battle”
Page 21: PHP Framework “Battle”

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

Page 22: PHP Framework “Battle”
Page 23: PHP Framework “Battle”

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

Page 24: PHP Framework “Battle”

CON

FIGU

RATI

ON

CONVENTION

CI CAKEZend

Page 25: PHP Framework “Battle”

Documentation

• Zend: – Complete, but fragmented – hard to follow.

• CI – Great

• CAKE– Outstanding

Page 26: PHP Framework “Battle”

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

Page 27: PHP Framework “Battle”

Performance

• Source: http://www.ruilog.com/blog/view/b6f0e42cf705.html

• Simple MVC logic, no DB connection

• See site for full hardware specs

Page 28: PHP Framework “Battle”

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

Page 29: PHP Framework “Battle”

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

Page 30: PHP Framework “Battle”

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

Page 31: PHP Framework “Battle”

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

Page 32: PHP Framework “Battle”

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

Page 33: PHP Framework “Battle”

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

Page 34: PHP Framework “Battle”

AND LASTLY…

Page 35: PHP Framework “Battle”

My Two Cents

• Too much abstraction is bad

• Understand the tradeoffs

• You will need to break out of the framework

• Stay curious

Page 36: PHP Framework “Battle”

<?echo “END”;die();

?>