Академический Документы
Профессиональный Документы
Культура Документы
MVC
Model
Data layer
View
Presentation layer
Controller
Logic layer
Typical Flow
2
4
Client
Datab
ase
Script
1
MVC Flow
Continue..
6. The controller processes the data and
outputs to the view file.
7. The view adds any design or display data to
the controller output and sends its output to
the clients browser
WEB SERVER
request for
/tasks/index
1 Request
TasksController
2 Index
Layout
{tasks_controller.ph
p}
Index
ToDo
Method Method
{tasks.thtml
} Tasks
Index
View
5
Done
Method
Index View
Tasks
selected
Tasks
Undo
Method
Metho
3
d Data
Called
Requested
Model Task
{task.php}
Table tasks
Response
Data
returned
DATABASE
Index
Views
Index
View
View
View
combined
with
{index.thtml
layout
todo.thtml
done.thtml}
MVC FLOW
CakePHP
A framework for developing applications in
PHP
Inspired by Ruby on Rails
Follows MVC design pattern
Convention over configuration
Helpers
Cake comes with standard HTML, Ajax, and
Customizable Elements
You can customize each of Cakes features to fit
your application. For example, you can bring
FCKeditor, the popular WYSIWYG editor for web
browsers, into Cake as a plug-in.
Using customized helpers, you can bring all the
functionality of FCKeditor into your Cake
application and actually trim out extra lines of
PHP code to get it working.
Other Features
Cake offers, its repository of other powerful
CakePHP
Framework
app/
config/
controllers/
models/
plugins/
tmp/
vendors/
views/
webroot/
cake/
config/
docs/
libs/
vendors/
Folder
What it Contains
config
controllers
locale
models
plugins
tmp
vendors
views
webroot
Controller Extension
A Component is a class that aids in controller
View Extension
A Helper is a class that aids in view logic.
Model Extension
Behaviors work as ways to add common
action logic
beforeRender(), executed after controller
logic, but before the view is rendered
afterFilter(), executed after all controller logic,
including the view render. There may be no
difference between afterRender() and
afterFilter() unless youve manually made a
call to render() in your controller action and
have included some logic after that call.
Application Extension
Controllers, helpers and models each have a
Convention Over
Configuration
File and ClassName Convention
In general, filenames are underscored while
CamelCased.
Ex:-Person, BigPerson, and ReallyBigPerson
Table names corresponding to CakePHP
models are plural and underscored.
The underlying tables for the above
mentioned models would be people,
big_people, and really_big_people,
respectively.
Controller Convention
Controller classnames are plural,
Continue..
he first method you write for a controller