cake php 3 presentaion

9
CAKE 3 Introduction to CakePHP 3

Upload: glslarmenta

Post on 12-Apr-2017

430 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Cake PHP 3 Presentaion

CAKE 3Introduction to CakePHP 3

Page 2: Cake PHP 3 Presentaion

CAKE 3CakePHP 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) formatConventions Over Configuration

Page 3: Cake PHP 3 Presentaion

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.

Page 4: Cake PHP 3 Presentaion

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).

Page 5: Cake PHP 3 Presentaion

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);

Page 6: Cake PHP 3 Presentaion

➤ 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.

Page 7: Cake PHP 3 Presentaion

use Cake\ORM\TableRegistry;Controller:$users = TableRegistry::get(‘Users’);

View:<?php foreach ($users as $user): ?> <li class="user"> <?= $this->element('user', ['user' => $user]) ?> </li><?php endforeach; ?>

Page 8: Cake PHP 3 Presentaion

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

Page 9: Cake PHP 3 Presentaion

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 Cake3Solution: Redesigned the system and Adopt Cake3 standard