SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
CakePHP Framework
Cake chefs:
Mohamed Samir
Moustafa Badawy
Agenda
• Introduction.
• MVC model of cakePHP.
• Folders structure and configurations.
• Controllers, Models and Views.
• Final look on the model.
• A big demo.
Introduction
• Cakephp = Free + OpenSource
• Some Features:
– Active, friendly community
– Compatible with versions 4 and 5 of PHP
– MVC architecture
– Built-in validation
– Works from any web site directory, with little to
no Apache configuration involved.
MVC
• CakePHP follows the MVC software design
pattern.
– The Model represents the application data
– The View renders a presentation of model data
– The Controller handles and routes requests made
by the client
MVC (cont.)
http://www.example.com/cakes/buy
MVC (cont.)
http://www.example.com/cakes/buy
Folder Structure
• Cakephp folder:
– App
– Cake [The core file of cake is here]
– Vendors [ Third-party PHP libraries is here]
– .htaccess
– index.php
– README
Folder Structure (cont.)
• Any application:
CakePHP Conventions
• Conventions => you may feel that it will waste
your time while it is actually saving it !! ?
• Because it gives you free functionality
• Conventions for:
– Model and database
– Controller
– Views
CakePHP Conventions (cont.)
• Any PHP file > underscored
• Like> any_file.php
• Any Class > CamelCased
• Like> anyClass
• Model classes > singular and CamelCased
• Like > Person, BigPerson
• Database tables > plural and underscored
• Like> persons, big_persons
• Controllers> CamelCased, and end ‘Controller’
• Like>PersonController
CakePHP Conventions (cont.)
• Database table:
• "people"
• Model class:
• "Person", found at /app/models/person.php
• Controller class:
• "PeopleController", found at /app/controllers/people_controller.php
• View template, found at
• /app/views/people/index.ctp
• Using these conventions, CakePHP knows that a request to
http://example.com/people/ maps to a call on the index() function of the
PeopleController, where the Person model is automatically available (and
automatically tied to the ‘people’ table in the database), and renders to a
file. None of these relationships have been configured by any means other
than by creating classes and files that you’d need to create anyway
CakeConfiguration
• Configurations needed:
– Database configuration
– To be able to connect a database to your application by giving
the parameters needed like username…etc
– Core configuration
– Here you configure application settings like sessions,
caching,…etc
– Routes configurations
– Here you configure how to parse a Url and what actions to
take then.
Database Configurations
• Can be found at > app/config/database.php
Core Configurations
Variable Description
debug 0 = Production mode. No output.
1 = Show errors and warnings.
2 = Show errors, warnings, and SQL.
3 = Show errors, warnings, SQL, and complete
controller dump.
Session.save -php = Use the default PHP session storage.
-cake = Store session data in /app/tmp
-database = store session data in a database
table.
Cache.disable When set to true, caching is disabled site-
wide.
Session.table The name of the table (not including any
prefix) that stores session information.
Session.*
Routes Configurations
• Found at > app/config/routes.php
• Example:
Enough Configurations :)
• Main components structure:
• Controller classes structure
• Model classes structure
• Views structure
Controller classes structure
Controller
AppController
Any controller
shares its attributes and
parameters with all its children
controllers
Controller classes structure
• Attributes:
• Interacting with views & Model:
Model Interaction
View Interaction
Model classes structure
Model
AppModel
Any model
Model classes structure
• Example:
Views structure
• Example:
Header for all pages
Page content
Footer for all pages
Final view before the Demo
Controller Model
View
data
2
3
1
6
5
4
Find()
Save(data)
set(data)
Render(view)
Logic
Demo
Show time
References
• http://book.cakephp.org
• http://aidanlister.com/2009/05/creating-a-
community-in-five-minutes-with-cakephp/
Thanks
Any Questions ?


Mais conteúdo relacionado

Mais procurados

Mais procurados (19)

Configurare http mule
Configurare http muleConfigurare http mule
Configurare http mule
 
Mule esb
Mule esbMule esb
Mule esb
 
Mule connector for ibm® as400
Mule connector for ibm® as400Mule connector for ibm® as400
Mule connector for ibm® as400
 
Basic example using for each component
Basic example using for each componentBasic example using for each component
Basic example using for each component
 
Expression filter in Mule
Expression filter in MuleExpression filter in Mule
Expression filter in Mule
 
Logger
LoggerLogger
Logger
 
Mule message processor or routers
Mule message processor or routersMule message processor or routers
Mule message processor or routers
 
Logger
LoggerLogger
Logger
 
Choice component in mule
Choice component in mule Choice component in mule
Choice component in mule
 
sample1
sample1sample1
sample1
 
Asp.net,mvc
Asp.net,mvcAsp.net,mvc
Asp.net,mvc
 
Jsp
JspJsp
Jsp
 
Asp.net With mvc handson
Asp.net With mvc handsonAsp.net With mvc handson
Asp.net With mvc handson
 
Word press 01
Word press 01Word press 01
Word press 01
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
 
For each component in mule
For each component in muleFor each component in mule
For each component in mule
 
Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400Anypoint connectorfor ibm as 400
Anypoint connectorfor ibm as 400
 
Mobile for web
Mobile for webMobile for web
Mobile for web
 
Web profiler in drupal 8
Web profiler in drupal 8Web profiler in drupal 8
Web profiler in drupal 8
 

Destaque

Karens Portfolio 2000 2010
Karens Portfolio 2000 2010Karens Portfolio 2000 2010
Karens Portfolio 2000 2010Karen_Sampson
 
Midia Kit - Blog Quarto Geek 2015
Midia Kit - Blog Quarto Geek 2015Midia Kit - Blog Quarto Geek 2015
Midia Kit - Blog Quarto Geek 2015Karen Patricia Lira
 
UPDATE: HOPE foundation - Flood Response - June 27, 2013
UPDATE:  HOPE foundation - Flood Response - June 27, 2013UPDATE:  HOPE foundation - Flood Response - June 27, 2013
UPDATE: HOPE foundation - Flood Response - June 27, 2013Marcia Scaggs
 
HOPE worldwide's HIV/AIDS Programs
HOPE worldwide's HIV/AIDS ProgramsHOPE worldwide's HIV/AIDS Programs
HOPE worldwide's HIV/AIDS ProgramsMarcia Scaggs
 
Bringing Hope and Health
Bringing Hope and Health Bringing Hope and Health
Bringing Hope and Health Marcia Scaggs
 
The Quality of Life of Typhoon Sendong Survivors
The Quality of Life of Typhoon Sendong SurvivorsThe Quality of Life of Typhoon Sendong Survivors
The Quality of Life of Typhoon Sendong SurvivorsHope Alcantara
 
HOPEww Philippines Response to Typhoon Haiyan Survivors
HOPEww Philippines Response to Typhoon Haiyan SurvivorsHOPEww Philippines Response to Typhoon Haiyan Survivors
HOPEww Philippines Response to Typhoon Haiyan SurvivorsMarcia Scaggs
 

Destaque (8)

Mj christ(2)
Mj christ(2)Mj christ(2)
Mj christ(2)
 
Karens Portfolio 2000 2010
Karens Portfolio 2000 2010Karens Portfolio 2000 2010
Karens Portfolio 2000 2010
 
Midia Kit - Blog Quarto Geek 2015
Midia Kit - Blog Quarto Geek 2015Midia Kit - Blog Quarto Geek 2015
Midia Kit - Blog Quarto Geek 2015
 
UPDATE: HOPE foundation - Flood Response - June 27, 2013
UPDATE:  HOPE foundation - Flood Response - June 27, 2013UPDATE:  HOPE foundation - Flood Response - June 27, 2013
UPDATE: HOPE foundation - Flood Response - June 27, 2013
 
HOPE worldwide's HIV/AIDS Programs
HOPE worldwide's HIV/AIDS ProgramsHOPE worldwide's HIV/AIDS Programs
HOPE worldwide's HIV/AIDS Programs
 
Bringing Hope and Health
Bringing Hope and Health Bringing Hope and Health
Bringing Hope and Health
 
The Quality of Life of Typhoon Sendong Survivors
The Quality of Life of Typhoon Sendong SurvivorsThe Quality of Life of Typhoon Sendong Survivors
The Quality of Life of Typhoon Sendong Survivors
 
HOPEww Philippines Response to Typhoon Haiyan Survivors
HOPEww Philippines Response to Typhoon Haiyan SurvivorsHOPEww Philippines Response to Typhoon Haiyan Survivors
HOPEww Philippines Response to Typhoon Haiyan Survivors
 

Semelhante a Introduction to CakePHP

Asp 1-mvc introduction
Asp 1-mvc introductionAsp 1-mvc introduction
Asp 1-mvc introductionFajar Baskoro
 
MVCL pattern, web flow, code flow, request and response in OpenCart
MVCL pattern, web flow, code flow, request and response in OpenCartMVCL pattern, web flow, code flow, request and response in OpenCart
MVCL pattern, web flow, code flow, request and response in OpenCartSelf
 
June 10th: The SugarCRM Platform
June 10th: The SugarCRM PlatformJune 10th: The SugarCRM Platform
June 10th: The SugarCRM Platformticomixcrm
 
June 10th: The SugarCRM Platform
June 10th: The SugarCRM PlatformJune 10th: The SugarCRM Platform
June 10th: The SugarCRM PlatformMatthew Cooke
 
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
TXLF: Chef- Software Defined Infrastructure Today & TomorrowTXLF: Chef- Software Defined Infrastructure Today & Tomorrow
TXLF: Chef- Software Defined Infrastructure Today & TomorrowMatt Ray
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8Thomas Robbins
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
 
(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEP(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEPBIOVIA
 
Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3kidtangerine
 
Cloud computing 3702
Cloud computing 3702Cloud computing 3702
Cloud computing 3702Jess Coburn
 
Rapid Development With CakePHP
Rapid Development With CakePHPRapid Development With CakePHP
Rapid Development With CakePHPEdureka!
 
Intro to CakePHP 1.3
Intro to CakePHP 1.3Intro to CakePHP 1.3
Intro to CakePHP 1.3Adam Culp
 
06 integrating extra features and looking forward
06   integrating extra features and looking forward06   integrating extra features and looking forward
06 integrating extra features and looking forwardМарина Босова
 
4. Web programming MVC.pptx
4. Web programming  MVC.pptx4. Web programming  MVC.pptx
4. Web programming MVC.pptxKrisnaBayu41
 
Building Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHPBuilding Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHPEdureka!
 
4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part II4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part IIRohit Rao
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Codeindiver
 

Semelhante a Introduction to CakePHP (20)

Asp 1-mvc introduction
Asp 1-mvc introductionAsp 1-mvc introduction
Asp 1-mvc introduction
 
MVCL pattern, web flow, code flow, request and response in OpenCart
MVCL pattern, web flow, code flow, request and response in OpenCartMVCL pattern, web flow, code flow, request and response in OpenCart
MVCL pattern, web flow, code flow, request and response in OpenCart
 
cakephp UDUYKTHA (1)
cakephp UDUYKTHA (1)cakephp UDUYKTHA (1)
cakephp UDUYKTHA (1)
 
June 10th: The SugarCRM Platform
June 10th: The SugarCRM PlatformJune 10th: The SugarCRM Platform
June 10th: The SugarCRM Platform
 
June 10th: The SugarCRM Platform
June 10th: The SugarCRM PlatformJune 10th: The SugarCRM Platform
June 10th: The SugarCRM Platform
 
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
TXLF: Chef- Software Defined Infrastructure Today & TomorrowTXLF: Chef- Software Defined Infrastructure Today & Tomorrow
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEP(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEP
 
Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3
 
Cloud computing 3702
Cloud computing 3702Cloud computing 3702
Cloud computing 3702
 
Rapid Development With CakePHP
Rapid Development With CakePHPRapid Development With CakePHP
Rapid Development With CakePHP
 
Intro to CakePHP 1.3
Intro to CakePHP 1.3Intro to CakePHP 1.3
Intro to CakePHP 1.3
 
Ember - introduction
Ember - introductionEmber - introduction
Ember - introduction
 
06 integrating extra features and looking forward
06   integrating extra features and looking forward06   integrating extra features and looking forward
06 integrating extra features and looking forward
 
4. Web programming MVC.pptx
4. Web programming  MVC.pptx4. Web programming  MVC.pptx
4. Web programming MVC.pptx
 
Building Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHPBuilding Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHP
 
4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part II4. introduction to Asp.Net MVC - Part II
4. introduction to Asp.Net MVC - Part II
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Code
 
Cake PHP
Cake PHPCake PHP
Cake PHP
 

Introduction to CakePHP