2. Agenda
• Introduction.
• MVC model of cakePHP.
• Folders structure and configurations.
• Controllers, Models and Views.
• Final look on the model.
• A big demo.
3. 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.
4. 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
9. 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
10. 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
11. 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
12. 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.
14. 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.*