cakephp 3
TRANSCRIPT
CakePHP 3
➔ Ambiente de desenvolvimento
Vagrant
➔ Composer● Download
curl -sS https://getcomposer.org/installer | php
● composer.json○ require vendor/name: version○ php composer.phar install○ composer.lock○ php composer.phar update dependencies
& lock file○ https://packagist.org/
➔ Criando um novo projetophp composer.phar create-project cakephp/app
lovejobs
➔ Estrutura de arquivosConfigConsoleController
Componentindex.phpLibLocaleModel
BehaviorDatasource
PluginTesttmpVendorView
ElementsEmailsLayoutsHelper
webroot
composer.jsoncomposer.lockconfigindex.phppluginssrc
ConsoleController
ComponentModel
BehaviorEntityTable
TemplateElementEmailLayout
ViewHelper
teststmpvendorlogswebroot
➔ Configuração● bootstrap.php● paths.php● autoload.php● bootstrap_cli.php● routes.php
● app.php○ Debug (true / false)○ App path configurations○ Security.salt○ Asset.timestamp○ Cache configuration○ Email transports & configuration ○ Datasource configuration○ Log configuration○ Session handler configuration
➔ AplicaçãoCompanies and Users
Users create Reviews (Public / Private)
Reviews belongsTo Company
https://www.dropbox.com/s/dz1qaezf43jve3y/schema.sql?dl=0
➔ Migrations● Phinx
http://phinx.org
● Criando○○ bake migration CreateCompanies○ bake migration create_companies○ bake migration addRatingToCompany○ bake migration removeRatingToCompany○ migrations create MyCustomMigration○ bake migration_snapshot initial
● Aplicando○ migrations migrate○ migrations migrate -t <version>
● Revertendo○ migrations rollback○ migrations rollback -t <version>
● migrations status● migrations mark_migrated
➔ Bake/bin/cake bake all <model>
➔ Request
➔ ModelsTables
● Criar consultas● Fornecedor finds● Validar e salvar entidades● Deletar entidades● Definir associações● Callbacks● Behaviors
Queries
Entidades
CakePHP\Database\Connection
CakePHP\Database\Dialect
CakePHP\Database\Type
CakePHP\Database\Table
CakePHP\Database\Behavior
CakePHP\Database\Query
CakePHP\Database\ResultSet
CakePHP\Database\Entity
➔ ModelsRecursive
Containable
afterFind callback
Virtual fields
➔ ControllersAppController
initialize()
$uses -> loadModel()
Views
set(‘name’, $value)
render(‘template’)
Controll flow
redirect($url, $code)
Callbacks
beforeFilter($event)
beforeRender($event)
afterFilter($event)
Components
Helpers
➔ ControllersRequest
$this->request->params
$this->request->param($key)
$this->request->query($key)
$this->request->data($key)
$this->request->is(‘detector’)
post / get / ajax / mobile / ssl
$this->request->session()
need screenshot for cakephp request debug
➔ ComponentesSession, Flash
Cookie
Auth
Security, Csrf
RequestHandler
Paginator
Acl -> https://www.github.com/cakephp/acl
➔ ViewsViews, Elements, Layouts, Helpers
➔ HelpersFlash, Form, Html, Number, Paginator, Time, Url
➔ Authentication
➔ ACL