Table of Contents : Le Manuel
- 1 Principes de base de CakePHP
- 2 Développer avec CakePHP
- 2.1 Pré-requis
- 2.2 Préparation à l'installation
- 2.3 Installation
- 2.4 Configuration
- 2.5 Contrôleurs
- 2.5.1 Introduction
- 2.5.2 Attributs des Contrôleurs
- 2.5.3 Méthodes des Contrôleurs
- 2.6 Components
- 2.7 Modèles
- 2.7.1 Introduction
- 2.7.2 Champs "automagiques" des Modèles
- 2.7.3 Attributs des Modèles
- 2.7.4 Méthodes du Modèle
- 2.7.5 Associations
- 2.7.6 DataSources
- 2.7.7 Behaviors
- 2.8 Views
- 2.9 Helpers
- 2.10 Scaffolding
- 2.11 The CakePHP Console
- 2.12 Code Generation with Bake
- 2.13 Plugins
- 2.14 Global Constants and Functions
- 3 Tâches courantes avec CakePHP
- 3.1 Validation des données
- 3.1.1 Règles simples
- 3.1.2 Une règle par champ
- 3.1.3 Plusieurs règles par champs
- 3.1.4 Built-in Validation Rules
- 3.1.4.1 alphaNumeric
- 3.1.4.2 between
- 3.1.4.3 blank
- 3.1.4.4 cc
- 3.1.4.5 comparison
- 3.1.4.6 date
- 3.1.4.7 decimal
- 3.1.4.8 email
- 3.1.4.9 equalTo
- 3.1.4.10 extension
- 3.1.4.11 file
- 3.1.4.12 ip
- 3.1.4.13 isUnique
- 3.1.4.14 minLength
- 3.1.4.15 maxLength
- 3.1.4.16 money
- 3.1.4.17 multiple
- 3.1.4.18 numeric
- 3.1.4.19 phone
- 3.1.4.20 postal
- 3.1.4.21 range
- 3.1.4.22 ssn
- 3.1.4.23 url
- 3.1.5 Custom Validation Rules
- 3.1.6 Validating Data from the Controller
- 3.2 Data Sanitization
- 3.3 Error Handling
- 3.4 Debugging
- 3.5 Caching
- 3.6 Logging
- 3.7 Testing
- 3.8 Localization & Internationalization
- 3.9 Pagination
- 3.1 Validation des données
- 4 Composants intégrés
- 4.1 Access Control Lists
- 4.2 Authentication
- 4.3 Sessions
- 4.4 Benefits
- Composant Security
- 4.6 Email
- 4.7 Controller
- 6 Helpers intégrés
- 6.1 Forms
- 6.1.1 Forms
- 6.1.2 Fermeture du Formulaire
- 6.1.3 Closing the Form
- 6.1.3.1 Automagic Form Elements
- 6.1.3.2 $options[‘type’]
- 6.1.3.3 $options[‘before’], $options[‘between’] and $options[‘after’]
- 6.1.3.4 $options[‘options’]
- 6.1.3.5 $options[‘multiple’]
- 6.1.3.6 $options[‘maxLength’]
- 6.1.3.7 $options[‘div’]
- 6.1.3.8 $options[‘label’]
- 6.1.3.9 $options[‘id’]
- 6.1.3.10 $options[‘error’]
- 6.1.3.11 $options[‘selected’]
- 6.1.3.12 $options[‘rows’], $options[‘cols’]
- 6.1.3.13 $options[‘empty’]
- 6.1.3.14 $options[‘timeFormat’]
- 6.1.4 File Fields
- 6.1.5 Eléments du Formulaire - Méthodes Spécifiques
- 6.2 Form Element-Specific Methods
- 6.3 XML
- 6.4 Inserting Well-Formatted elements
- 6.5 Methods
- 6.6 Methods
- 6.7 Clearing the Cache
- 6.8 Form
- 6.9 format
- 6.10 Text
- 6.1 Forms
- 7 Exemples
- 8 Le tutoriel du blog CakePHP
- 8.1 Obtenir Cake
- 8.2 Créer la base de données du blog
- 8.3 Configurer la base de données Cake
- 8.4 Configuration facultative
- 8.5 Une note sur mod_rewrite
- 8.6 Créer un Modèle "Post"
- 8.7 Créer un Contrôleur "Posts"
- 8.8 Créer les Vues Post
- 8.9 Ajouter des Posts
- 8.10 Validation des données
- 8.11 Supprimer des Posts
- 8.12 Editer des Posts
- 8.13 Routes
- 8.14 Conclusion
- 9 Authentification facile d'un utilisateur
- 10 Simple User Authentication
$components, $helpers et $uses
The next most oft used controller attributes tell CakePHP what helpers, components, and models you’ll be using in conjunction with the current controller. Using these attributes make these MVC classes available to the controller as a class variable ($this->ModelName, for example).
Please note that each controller has some of these classes available by default, so you may not need to configure your controller at all.
Controllers have access to their primary model available by default. Our RecipesController will have the Recipe model class available at $this->Recipe, and our ProductsController also features the Product model at $this->Product.
The Html- and SessionHelpers are always available by default, as is the SessionComponent. To learn more about these classes, be sure to check out their respective sections later in this manual.
Let’s look at how to tell a CakePHP controller that you plan to use additional MVC classes.
<?php
class RecipesController extends AppController {
var $name = 'Recipes';
var $uses = array('Recipe', 'User');
var $helpers = array('Html', 'Ajax');
var $components = array('Session', 'Email');
}
?>
<?phpclass RecipesController extends AppController {var $name = 'Recipes';var $uses = array('Recipe', 'User');var $helpers = array('Html', 'Ajax');var $components = array('Session', 'Email');}?>
When defining these attributes, make sure to include the default classes (like including the HtmlHelper in the $helpers array, for example) if you intend to use them.

login to add a comment