Une introduction
Par Padraig Galvin
Présentation du framework
●

Architecture Model View Controller (MVC)

●

Programmation orientée objet (OOP)

●

Crée en 2005 (pour PHP 4.3)

●

Inspirée de Ruby on Rails
–

Convention over configuration

–

DRY : don't repeat yourself

●

Licence MIT (open source)

●

Projet actif avec des mise a jour fréquente

●

PHP version 5.2.8 +
Caractéristiques
●

●

●

●

Validation et assainissement des données simple
Gestion des associations entre les données
automatique
Système de templates avec des layouts, éléments
réutilisables et helpers
Composants et utilitaires intégrés pour gérer la cache,
les emails, cookies …

●

Sessions, authentification et contrôle d'accès

●

Internationalisation (i18n) et localisation (i10n)

●

Échafaudage et génération de code
Structure du répertoire
/app
/Config
/Console
/Controller
/Lib
/Locale
/Model
/Plugin
/Test
/Vendor
/View
/tmp
/webroot
/lib
/Cake
/plugins
/vendors

← Votre application
← Configuration : routage, base de donné, sessions …
← Scripts CLI/Shell (Cron jobs).

← Traductions Gettext (fichiers PO).

← Unit tests (PHPUnit).

← Fichiers temporaire : cache, logs …
← Répertoire publique : CSS, JS, images …

← Cœur de CakePHP
Les conventions
Route
Controller

Action (method)

View

Model

Database table

/articles/add
GET / POST

/articles

/articles/edit/36

Class: ArticlesController
File: app/Controller/ArticlesController.php
index()

add()

edit($id)

app/View/Articles/
index.ctp

app/View/Articles/
add.ctp

app/View/Articles/
edit.ctp

Class: Article
File: app/Model/Article.php
articles
Un simple exemple
Exemple d'application :

Le schéma
clients
id
name
email
created
modified

tags
id
name

tickets
id
client_id
description
created
modified

tags_tickets
id
tag_id
ticket_id
Exemple d'application :

Les modèles
/app/Model/Client.php

/app/Model/Tag.php

/app/Model/Ticket.php
Exemple d'application :

Les relations
/app/Model/Client.php

/app/Model/Tag.php

/app/Model/Ticket.php
Exemple d'application :

Validation de donnée
/app/Model/Client.php

Règles de validation disponibles
alphaNumeric
between
blank
boolean
cc
comparison
custom
date
datetime
decimal
email
equalTo
extension
fileSize
inList
ip
luhn

maxLength
mimeType
minLength
money
multiple
naturalNumber
notEmpty
numeric
phone
postal
range
ssn
time
uploadError
url
userDefined
uuid
Exemple d'application :

Liste des clients (index)
Un petit test
/app/Controller/ClientsController.php

/app/View/Client/index.ctp

example.com/clients

/app/View/Client/index.ctp
find(string $type, array $params)

first
all
count
list
threaded
neighbors

conditions
recursive
fields
order
limit
...
Exemple d'application :

Afficher un client (view)
/app/Controller/ClientsController.php

Un petit test
/app/View/Client/view.ctp

example.com/clients/view/3
/app/View/Client/view.ctp
Exemple d'application :

Ajouter un client (add)
/app/Controller/ClientsController.php

Les données
/app/Controller/ClientController.php

/app/View/Client/add.ctp

POST : example.com/clients/add
Exemple d'application :

Ajouter un client (add)
/app/View/Client/add.ctp - vues alternatifs
Minimal :

Précis :

HTML généré :

HTML généré :
Exemple d'application :

modifier un client (edit)
/app/Controller/ClientsController.php

/app/View/Client/edit.ctp
Exemple d'application :

supprimer un client (delete)
/app/Controller/ClientsController.php

Lien pour supprimer
Astuces et conseils
●

●

●
●

●

Commencez par les tutoriels de la
documentation officielle
Prenez le temps de réfléchir à votre schéma de
base de données
Utilisez bake avec des templates personnalisé
Ne pas réinventez la roue, surtout pour la
sécurité
Respectez les conventions !
Version 3.0
●

PHP version 5.4 +

●

Installation avec Composer (http://getcomposer.org/)

●

Namespaces

●

Modèle amélioré avec données en forme d'objet

●

Configuration consolidée

●

Et beaucoup plus …
Ressources
●

Sites et téléchargements :
–
–

●

http://cakephp.org
http://www.cakephp-fr.org/

Le « Cookbook » (documentation) :
–

●

Support :
–
–
–

●

http://book.cakephp.org/2.0/fr/
https://groups.google.com/forum/#!topic/cakephp/
http://stackoverflow.com/tags/cakephp
irc://irc.freenode.net/cakephp

Code source :
–

https://github.com/cakephp/cakephp

Contenu connexe

ODP
Introduction à CakePHP
ODP
Formation PHP avancé - Cake PHP
PPTX
Meetup CakePHP Amiens / 25 mars 2015
PDF
Bonnes pratiques de developpement en PHP
PDF
Symfony2: 30 astuces et bonnes pratiques
PPTX
Introduction à Symfony
PPTX
[2015] Laravel yet another framework
PDF
Alphorm.com Formation React : Les fondamentaux
Introduction à CakePHP
Formation PHP avancé - Cake PHP
Meetup CakePHP Amiens / 25 mars 2015
Bonnes pratiques de developpement en PHP
Symfony2: 30 astuces et bonnes pratiques
Introduction à Symfony
[2015] Laravel yet another framework
Alphorm.com Formation React : Les fondamentaux

Tendances (20)

PPTX
Spring & SpringBatch FR
PDF
Symfony
PDF
Cours php & Mysql - 5éme partie
PDF
AlterWay SolutionsLinux Outils Industrialisation PHP
PPTX
Architecture mvc
PPTX
Introduction au Framework Laravel
PDF
Mieux Développer en PHP avec Symfony
PPTX
Introduction à React
PPTX
Quoi de neuf à Devoxx France 2017 ?
PDF
Forum PHP 2010 - Les frameworks, essentiels dans-l-ecosysteme-php-xavier-laco...
PPTX
Symfony with angular.pptx
PDF
Intégration Continue PHP avec Jenkins CI
PDF
Zend Framework 2.0 - Le gestionnaire de modules
PDF
Alphorm.com Formation PowerShell : Niveau Initiation
PDF
Alphorm.com Formation React Package Manager : npm et yarn
PPTX
Introduction à AngularJS
PPT
Asp Au Service Des Mv Ps
PDF
Laravel Blade
PPTX
Workshop Spring - Session 1 - L'offre Spring et les bases
Spring & SpringBatch FR
Symfony
Cours php & Mysql - 5éme partie
AlterWay SolutionsLinux Outils Industrialisation PHP
Architecture mvc
Introduction au Framework Laravel
Mieux Développer en PHP avec Symfony
Introduction à React
Quoi de neuf à Devoxx France 2017 ?
Forum PHP 2010 - Les frameworks, essentiels dans-l-ecosysteme-php-xavier-laco...
Symfony with angular.pptx
Intégration Continue PHP avec Jenkins CI
Zend Framework 2.0 - Le gestionnaire de modules
Alphorm.com Formation PowerShell : Niveau Initiation
Alphorm.com Formation React Package Manager : npm et yarn
Introduction à AngularJS
Asp Au Service Des Mv Ps
Laravel Blade
Workshop Spring - Session 1 - L'offre Spring et les bases
Publicité

En vedette (20)

PDF
Assemblée Générale An Daol Vras 120914
PDF
Présentation Smart Talk - Lauréat Startup Weekend Brest
PPTX
Pitch Tydus.it - Startup Weekend Brest
PDF
Book lab - Startup Weekend Brest
PPTX
Kitatoutfaire.fr - Startup Weekend Brest
PPTX
Guide Your Tribes - Startup Weekend Brest
PDF
Covoitdeboite - Startup Weekend Brest
PPTX
Coast Saver - Startup Weekend Brest
PDF
B.Dadoum - Startup Weekend Brest
PPT
Les Créas - Startup Weekend Brest
PDF
Minute Papillotte - Startup Weekend Brest
PDF
A Ta Boutique - Startup Weekend Brest
PDF
de Google Maps à OpenStreetMap
PPS
3.2 Les Infrastructures de données spatiales régionales développées dans le p...
PDF
Like A Coach - Startup Weekend Brest
PDF
Shoes Me - Startup Weekend Brest
PDF
Installation apache mandriva
DOC
PostgreSQL
PPTX
PPTX
How to pitch, new version
Assemblée Générale An Daol Vras 120914
Présentation Smart Talk - Lauréat Startup Weekend Brest
Pitch Tydus.it - Startup Weekend Brest
Book lab - Startup Weekend Brest
Kitatoutfaire.fr - Startup Weekend Brest
Guide Your Tribes - Startup Weekend Brest
Covoitdeboite - Startup Weekend Brest
Coast Saver - Startup Weekend Brest
B.Dadoum - Startup Weekend Brest
Les Créas - Startup Weekend Brest
Minute Papillotte - Startup Weekend Brest
A Ta Boutique - Startup Weekend Brest
de Google Maps à OpenStreetMap
3.2 Les Infrastructures de données spatiales régionales développées dans le p...
Like A Coach - Startup Weekend Brest
Shoes Me - Startup Weekend Brest
Installation apache mandriva
PostgreSQL
How to pitch, new version
Publicité

Similaire à Cakephp (20)

PPTX
Formation cakephp
ODP
Présentation de CakePHP, 22/04/2010
PDF
Apéro PHP Amiens - l'ORM de CakePHP, c'est du gâteau !
PPTX
Symfony3 overview
ODP
CakePHP formation
PDF
#J2Code2018 - Mettez du feu à vos applications avec CodeIgniter
PPTX
Framework php « Codeignitor »
PDF
WonderPicture
PDF
Wonder_picture_nguyen_patois_rollot_scala
PPTX
CodeIgniter_created_by_amine_oubouisk.pptx
PDF
Un exemple élémentaire d'application MVC en PHP
PPTX
Les framework mvc
PDF
Etapes
PDF
cours.symfony.web2pouringenieurseninformatique
PPT
Fondamentaux d'architecture d'une application Flex
PPT
Fondamentaux d'architecture d'une application Flex
ODP
Séminaire Ruby on Rails (novembre 2010)
PDF
ch5 - Le CRUD avec Laravel , aaa aaa aaa
PDF
Introduction au développement Web
PPTX
SOLID : les principes à l’origine du succès de Symfony et de vos applications
Formation cakephp
Présentation de CakePHP, 22/04/2010
Apéro PHP Amiens - l'ORM de CakePHP, c'est du gâteau !
Symfony3 overview
CakePHP formation
#J2Code2018 - Mettez du feu à vos applications avec CodeIgniter
Framework php « Codeignitor »
WonderPicture
Wonder_picture_nguyen_patois_rollot_scala
CodeIgniter_created_by_amine_oubouisk.pptx
Un exemple élémentaire d'application MVC en PHP
Les framework mvc
Etapes
cours.symfony.web2pouringenieurseninformatique
Fondamentaux d'architecture d'une application Flex
Fondamentaux d'architecture d'une application Flex
Séminaire Ruby on Rails (novembre 2010)
ch5 - Le CRUD avec Laravel , aaa aaa aaa
Introduction au développement Web
SOLID : les principes à l’origine du succès de Symfony et de vos applications

Plus de AnDaolVras (16)

PDF
Pitch Leter.io
PPT
Pitch Tipsit
PPTX
Pitch Cuistot du coin
PPT
Pitch Perform SW 2016
PPTX
Présentation Pomodoro
PDF
Introduction à OpenStack
PDF
Open stack in the bank, is it bankable?
PDF
DNS et bien commun
PDF
Presentation frenchtech brest
PDF
#ArchipelMolene, les données du SHOM
PDF
Orizon - Startup Weekend Brest
PPTX
Pitch trainig #1 - SWBrest
PPTX
PhPotes: Drupal
PPTX
PHPotes: Codeigniter
ODP
Phpotes #1 - 10.09.13
PDF
Présentation Satimo/Groupe MVG - Vitamin'C
Pitch Leter.io
Pitch Tipsit
Pitch Cuistot du coin
Pitch Perform SW 2016
Présentation Pomodoro
Introduction à OpenStack
Open stack in the bank, is it bankable?
DNS et bien commun
Presentation frenchtech brest
#ArchipelMolene, les données du SHOM
Orizon - Startup Weekend Brest
Pitch trainig #1 - SWBrest
PhPotes: Drupal
PHPotes: Codeigniter
Phpotes #1 - 10.09.13
Présentation Satimo/Groupe MVG - Vitamin'C

Cakephp