baking with cake php
TRANSCRIPT
Baking with CakePHP
- a practical overview by
Valberg Lárusson
MyRecipes-Online.com
What is CakePHP?
A framework for building PHP websites and applications.
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.
How does CakePHP do that?
• Library like reusable code• Convention over configuration• MVC for structure• ORM(ish) for database mapping
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)
MVC
• Model, database mapping• View, what the user sees• Controller, the business logic
http://book.cakephp.org/view/10/Understanding-Model-View-Controller >>
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 >>
The 15 minute Blog
1. Install CakePHP2. Create the Database3. Create the Model 4. Create the Controller5. Create Views
>>
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
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
Components
• Access Control Lists (Acl)• Authentication• Cookies• Email• Request Handling– (getClientIP(), getReferrer(), isMobile())
• Security Component• Sessions– A wrapper for $_SESSION + added methods
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
Helpers
• Ajax• Cache• Form• Html• Javascript• Number
• Paginator• RSS• Session• Text• Time• XML
Utility Libraries
• Inflector– Slug, pluralize,
tableize• String methods– uuid, insert
• XML parsing• Set– Array management
• Security methods– Hashing,
encrypting• Cache• HttpSocket– To fetch content
Console Applications
• Code generation• Schema management and migrations
Testing
• CakePHP integrates SimpleTest• Unit testing and Web testing• Test-driven development
A few Cake PHP websites
More websites
More websites
More websites
The big questions
• Performance• Speed• Load tolerance• Security• Stability and uptime
Room for improvements?
• Debugging tools• Documentation is reasonable• Integrated version control• Commercial support for enterprise
deployment• >>