SlideShare a Scribd company logo
CAKE 3Introduction to CakePHP 3
CAKE 3
CakePHP is a web development framework running on PHP 7
(min. PHP 5.5.9).
CakePHP is designed to make common web-development tasks
simple, and easy.
Follow MVC (Model, View, Controller) format
Conventions Over Configuration
Conventions Over Configuration
➤ CakePHP provides a basic organizational structure that covers
class names, filenames, database table names, and other
conventions. CakePHP provides that you can avoid needless
configuration and make a uniform application structure that
makes working with various projects simple.
CONVENTIONS OVER CONFIGURATION
➤ Table names will be plural (e.g., orders)
➤ The name of the primary key field will be id
➤ The names of any foreign key fields will be based on the
referenced table name followed by _id (e.g., the foreign key
into a customers table would be named customer_id).
LATEST IN CAKE3 IS THE NEW ORM !!!
➤ No more array in return.
➤ Cake3 return Entity/Object as return value
➤ Validation removed from Model
➤ Now its separated for reusable or more extensible
➤ Associations No Longer Defined as Properties
In ArticlesTable.php:
class ArticlesTable extends Table {
public function initialize(array $config) {
$this->belongsTo('Users');
}
}
➤ New api function patchEntity, removing not related data from saving
$user = $this->Users->patchEntity($user, $this->request->data);
➤ Cake’s ORM would by default retrieve any associated tables
when performing a query. As a result, a simple “find all” query
could potentially become quite bloated as the underlying SQL
would retrieve all data from all associated tables. In version 3,
this behavior is no longer the default.
use CakeORMTableRegistry;
Controller:
$users = TableRegistry::get(‘Users’);
View:
<?php foreach ($users as $user): ?>
<li class="user">
<?= $this->element('user', ['user' => $user]) ?>
</li>
<?php endforeach; ?>
REQUIREMENTS
➤ CakePHP 3.x supports PHP Version 5.4.16 and above.
➤ CakePHP 3.x requires the mbstring extension.
➤ CakePHP 3.x requires the intl extension.
➤ CakePHP should be installed with Composer
MIGRATION
➤ Upgrade tools for CakePHP meant to facilitate migrating from
CakePHP 2.x to 3.0.0.
Warning This tool is still under development and doesn't handle
all aspects of migrating.
POV: Do not migrate your project from Cake2 to Cake3
Solution: Redesigned the system and Adopt Cake3 standard

More Related Content

Cake PHP 3 Presentaion

  • 2. CAKE 3 CakePHP is a web development framework running on PHP 7 (min. PHP 5.5.9). CakePHP is designed to make common web-development tasks simple, and easy. Follow MVC (Model, View, Controller) format Conventions Over Configuration
  • 3. Conventions Over Configuration ➤ CakePHP provides a basic organizational structure that covers class names, filenames, database table names, and other conventions. CakePHP provides that you can avoid needless configuration and make a uniform application structure that makes working with various projects simple.
  • 4. CONVENTIONS OVER CONFIGURATION ➤ Table names will be plural (e.g., orders) ➤ The name of the primary key field will be id ➤ The names of any foreign key fields will be based on the referenced table name followed by _id (e.g., the foreign key into a customers table would be named customer_id).
  • 5. LATEST IN CAKE3 IS THE NEW ORM !!! ➤ No more array in return. ➤ Cake3 return Entity/Object as return value ➤ Validation removed from Model ➤ Now its separated for reusable or more extensible ➤ Associations No Longer Defined as Properties In ArticlesTable.php: class ArticlesTable extends Table { public function initialize(array $config) { $this->belongsTo('Users'); } } ➤ New api function patchEntity, removing not related data from saving $user = $this->Users->patchEntity($user, $this->request->data);
  • 6. ➤ Cake’s ORM would by default retrieve any associated tables when performing a query. As a result, a simple “find all” query could potentially become quite bloated as the underlying SQL would retrieve all data from all associated tables. In version 3, this behavior is no longer the default.
  • 7. use CakeORMTableRegistry; Controller: $users = TableRegistry::get(‘Users’); View: <?php foreach ($users as $user): ?> <li class="user"> <?= $this->element('user', ['user' => $user]) ?> </li> <?php endforeach; ?>
  • 8. REQUIREMENTS ➤ CakePHP 3.x supports PHP Version 5.4.16 and above. ➤ CakePHP 3.x requires the mbstring extension. ➤ CakePHP 3.x requires the intl extension. ➤ CakePHP should be installed with Composer
  • 9. MIGRATION ➤ Upgrade tools for CakePHP meant to facilitate migrating from CakePHP 2.x to 3.0.0. Warning This tool is still under development and doesn't handle all aspects of migrating. POV: Do not migrate your project from Cake2 to Cake3 Solution: Redesigned the system and Adopt Cake3 standard