baking with cake php

23

Click here to load reader

Upload: valberg

Post on 16-Apr-2017

6.741 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Baking With Cake Php

Baking with CakePHP

- a practical overview by

Valberg Lárusson

Page 2: Baking With Cake Php

MyRecipes-Online.com

Page 3: Baking With Cake Php

What is CakePHP?

A framework for building PHP websites and applications.

Page 4: Baking With Cake Php

What does that mean?

Its a bunch of PHP code which provides commonly used functionality so you don’t

have to create it your self.

Page 5: Baking With Cake Php

How does CakePHP do that?

• Library like reusable code• Convention over configuration• MVC for structure• ORM(ish) for database mapping

Page 6: Baking With Cake Php

How do I use it?

• Download the code• Extract to your project folder• Create your– Database table– Model– Controller– View– (or just get started with CRUD scaffolding)

Page 7: Baking With Cake Php

MVC

• Model, database mapping• View, what the user sees• Controller, the business logic

http://book.cakephp.org/view/10/Understanding-Model-View-Controller >>

Page 8: Baking With Cake Php

ORM

• Cake PHP uses an Ruby on Rails like Active Record system to map models to objects

• Not Cake’s strongest feature but pretty good

http://en.wikipedia.org/wiki/Object-relational_mapping >>

Page 9: Baking With Cake Php

The 15 minute Blog

1. Install CakePHP2. Create the Database3. Create the Model 4. Create the Controller5. Create Views

>>

Page 10: Baking With Cake Php

URL’s and SEO

• Cake uses mod_rewrite to provide readable URL’s

www.domain.com/controller/action/param1

• This is controlled via .htacess files• Can be turned off if .htacess is not read

Page 11: Baking With Cake Php

Routing

• Routing is a feature that maps URLs to controller actions.

• You can use Route configurations to define how your website maps your web addresses

• Example– Router::connect('/admin', array('controller' =>

'pages', 'action' => 'index', 'admin' => true));– Maps http://website.com/admin to the

admin_index action in the pages controller

Page 12: Baking With Cake Php

Components

• Access Control Lists (Acl)• Authentication• Cookies• Email• Request Handling– (getClientIP(), getReferrer(), isMobile())

• Security Component• Sessions– A wrapper for $_SESSION + added methods

Page 13: Baking With Cake Php

Behaviours

• Acl– integrate a model with your ACL system

• Containable– Improvement on recursive finds

• Translate– Table contains translations and the language is set in

either the Model or Controller• Tree– Assists in maintaining the structure of the site

Page 14: Baking With Cake Php

Helpers

• Ajax• Cache• Form• Html• Javascript• Number

• Paginator• RSS• Session• Text• Time• XML

Page 15: Baking With Cake Php

Utility Libraries

• Inflector– Slug, pluralize,

tableize• String methods– uuid, insert

• XML parsing• Set– Array management

• Security methods– Hashing,

encrypting• Cache• HttpSocket– To fetch content

Page 16: Baking With Cake Php

Console Applications

• Code generation• Schema management and migrations

Page 17: Baking With Cake Php

Testing

• CakePHP integrates SimpleTest• Unit testing and Web testing• Test-driven development

Page 18: Baking With Cake Php

A few Cake PHP websites

Page 19: Baking With Cake Php

More websites

Page 20: Baking With Cake Php

More websites

Page 21: Baking With Cake Php

More websites

Page 22: Baking With Cake Php

The big questions

• Performance• Speed• Load tolerance• Security• Stability and uptime

Page 23: Baking With Cake Php

Room for improvements?

• Debugging tools• Documentation is reasonable• Integrated version control• Commercial support for enterprise

deployment• >>