CAKEPHP
CakePHP is a free, open-source, rapid application
development(RAD) framework for PHP. It's a
foundational structure for programmers to create web
applications. Our primary goal is to enable you to work
in a structured and rapid manner–without loss of
flexibility. CakePHP takes the monotony out of web
development.
RAD
• RAD model is Rapid Application Development
model. It is a type of incremental model. In
RAD model the components or functions are
developed in parallel as if they were mini
projects.
Advantages of the RAD model:
• Reduced development time.
• Increases reusability of components
• Quick initial reviews occur
• Give support customer feedback
• Integration from very beginning solves a lot
of integration issues.
• RAD should be used when there is a need to create a
system that can be modularized in 2-3 months of time.
• It should be used if there’s high availability of designers
for modeling and the budget is high enough to afford
their cost along with the cost of automated code
generating tools.
• list of features you will enjoy when
using CakePHP:
• Active, friendly community
• Flexible licensing
• Compatible with versions 4 and 5 of PHP
• Integrated CRUD for database interaction
• Application scaffolding
• Code generation
• MVC architecture
• Request dispatcher with clean, custom URLs and
routes
• Built-in validation
Installation
Download CakePHP package
from http://cakephp.org/ and extract
that package and locate it your
xampp htdocs.
Run server (eg. Localhost/cakephp/)
Basics of CakePhp
•Folder Structure
• –App
• •Config: all configuration files
• •Models : application’s models, data sources and behaviors
• •Controllers : application’s controllers and components
• •Views : presentational files
• •Vendors : 3rdparty classes or libraries
• •Webroot: acts as document root for the application
• •Locale : stores string files for internationalization
• •Tmp: stores temporary data
• •Plugins: pluginpackages
• –Cake
• –Vendors
Steps
• •Creating the database
• •Creating a model
• •Creating a controller
• •Creating the views
Creating the database
• •Create a new table (name should be
according to the naming conventions)
• •Enter the data.
• •(Using phpmyadmin)
Creating a model
• •Separates the domain logic from presentation isolating
the application logic.
• •Extends AppModel(extends Model)
• •Contains data validation rules, association information and
methods specific to the table it uses.
• •For complete reference http://api.cakephp.org
• •Cakephpdynamically creates a model object
• class Book extends AppModel{
• var$name = ‘Book';
• }
• •We do can add some behaviors to each model.
Creating a controller
• •Manages the logic for a part of our application
• •Can access the model object by $this->Book
• class BooksControllerextends AppController{
• var$name = 'Books';
• function index() {
• $this->set('books', $this->Book->find('all'));
• }
• }
• •$this->loadModel(‘Article'); loads a different model
• •Components (packages of logic that are shared
between controllers)
Creating the views
• •Layouts (placed in /app/views/layouts)
• •Elements (reusable parts)
• •Helpers
• (var$helpers = array('Form', 'Html',
'Javascript', 'Time');)
Sample model
• <?php
• class Book extends AppModel
• {
• var$name = 'Book';
• var$validate = array(
• 'title' => array(
• 'rule' => 'notEmpty'
• ),
• 'author' => array(
• 'rule' => 'notEmpty'
• )
• );
• }
• ?>
Sample Controller
• <?php
• class BooksControllerextends AppController{
• var$name = 'Books';
• var$helpers = array('Html','Ajax','Javascript');
• function index()
• {
• $this->set('books', $this->Book->find('all'));
• }
• function view($id = null) {
• $this->Book->id = $id;
• $this->set('book', $this->Book->read());
• print_r($this->viewVars);
• }
• }
Sample view
• <h1>Books</h1>
• <table>
• <tr>
• <th>Id</th>
• <th>Title</th>
• <th>Author</th>
• </tr>
• <?phpforeach($books as $book: ?>
• <tr>
• <td><?phpecho $book*‘Book'+*'id'+; ?></td>
• <td>
• <?phpecho $html->link($book*‘Book+*'title'+,
• array('controller' => ‘books’, 'action' => 'view', $book*‘Book+*'id'+)); ?>
• </td>
• <td><?phpecho $book*‘Book+*‘author'+; ?></td>
• </tr>
• <?phpendforeach; ?>
• </table>
• The webserver rewrite rules direct the request to
webroot/index.php.
• Your application’s autoloader and bootstrap files are
executed.
• Any dispatch filters that are configured can handle the
request, and optionally generate a response.
• The dispatcher selects the appropriate controller & action
based on routing rules.
• The controller’s action is called and the controller interacts
with the required Models and Components.
• The controller delegates response creation to the View to
generate the output resulting from the model data.
• The view uses Helpers and Cells to generate the response
body and headers.
• The response is sent back to the client.
Thank You

Cakeph pppt

  • 1.
    CAKEPHP CakePHP is afree, open-source, rapid application development(RAD) framework for PHP. It's a foundational structure for programmers to create web applications. Our primary goal is to enable you to work in a structured and rapid manner–without loss of flexibility. CakePHP takes the monotony out of web development.
  • 2.
    RAD • RAD modelis Rapid Application Development model. It is a type of incremental model. In RAD model the components or functions are developed in parallel as if they were mini projects.
  • 3.
    Advantages of theRAD model: • Reduced development time. • Increases reusability of components • Quick initial reviews occur • Give support customer feedback • Integration from very beginning solves a lot of integration issues. • RAD should be used when there is a need to create a system that can be modularized in 2-3 months of time. • It should be used if there’s high availability of designers for modeling and the budget is high enough to afford their cost along with the cost of automated code generating tools.
  • 4.
    • list offeatures you will enjoy when using CakePHP: • Active, friendly community • Flexible licensing • Compatible with versions 4 and 5 of PHP • Integrated CRUD for database interaction • Application scaffolding • Code generation • MVC architecture • Request dispatcher with clean, custom URLs and routes • Built-in validation
  • 5.
    Installation Download CakePHP package fromhttp://cakephp.org/ and extract that package and locate it your xampp htdocs. Run server (eg. Localhost/cakephp/)
  • 6.
    Basics of CakePhp •FolderStructure • –App • •Config: all configuration files • •Models : application’s models, data sources and behaviors • •Controllers : application’s controllers and components • •Views : presentational files • •Vendors : 3rdparty classes or libraries • •Webroot: acts as document root for the application • •Locale : stores string files for internationalization • •Tmp: stores temporary data • •Plugins: pluginpackages • –Cake • –Vendors
  • 7.
    Steps • •Creating thedatabase • •Creating a model • •Creating a controller • •Creating the views
  • 8.
    Creating the database ••Create a new table (name should be according to the naming conventions) • •Enter the data. • •(Using phpmyadmin)
  • 9.
    Creating a model ••Separates the domain logic from presentation isolating the application logic. • •Extends AppModel(extends Model) • •Contains data validation rules, association information and methods specific to the table it uses. • •For complete reference http://api.cakephp.org • •Cakephpdynamically creates a model object • class Book extends AppModel{ • var$name = ‘Book'; • } • •We do can add some behaviors to each model.
  • 10.
    Creating a controller ••Manages the logic for a part of our application • •Can access the model object by $this->Book • class BooksControllerextends AppController{ • var$name = 'Books'; • function index() { • $this->set('books', $this->Book->find('all')); • } • } • •$this->loadModel(‘Article'); loads a different model • •Components (packages of logic that are shared between controllers)
  • 11.
    Creating the views ••Layouts (placed in /app/views/layouts) • •Elements (reusable parts) • •Helpers • (var$helpers = array('Form', 'Html', 'Javascript', 'Time');)
  • 12.
    Sample model • <?php •class Book extends AppModel • { • var$name = 'Book'; • var$validate = array( • 'title' => array( • 'rule' => 'notEmpty' • ), • 'author' => array( • 'rule' => 'notEmpty' • ) • ); • } • ?>
  • 13.
    Sample Controller • <?php •class BooksControllerextends AppController{ • var$name = 'Books'; • var$helpers = array('Html','Ajax','Javascript'); • function index() • { • $this->set('books', $this->Book->find('all')); • } • function view($id = null) { • $this->Book->id = $id; • $this->set('book', $this->Book->read()); • print_r($this->viewVars); • } • }
  • 14.
    Sample view • <h1>Books</h1> •<table> • <tr> • <th>Id</th> • <th>Title</th> • <th>Author</th> • </tr> • <?phpforeach($books as $book: ?> • <tr> • <td><?phpecho $book*‘Book'+*'id'+; ?></td> • <td> • <?phpecho $html->link($book*‘Book+*'title'+, • array('controller' => ‘books’, 'action' => 'view', $book*‘Book+*'id'+)); ?> • </td> • <td><?phpecho $book*‘Book+*‘author'+; ?></td> • </tr> • <?phpendforeach; ?> • </table>
  • 16.
    • The webserverrewrite rules direct the request to webroot/index.php. • Your application’s autoloader and bootstrap files are executed. • Any dispatch filters that are configured can handle the request, and optionally generate a response. • The dispatcher selects the appropriate controller & action based on routing rules. • The controller’s action is called and the controller interacts with the required Models and Components. • The controller delegates response creation to the View to generate the output resulting from the model data. • The view uses Helpers and Cells to generate the response body and headers. • The response is sent back to the client.
  • 17.