Saturday, April 30, 2016

Cake PHP Basic Aspects for the exam preparation

Posted by Tech Talim
Chapter-1
ê  naming a table ‘posts’ automatically hooks it to Post model
ê  CakePHP’s database configuration file is found in /app/Config/database.php.default.
ê  The security salt is used for generating hashes. Security.salt location is /app/Config/core.php
ê  The cipher seed is used for encrypt/decrypt strings. Change the default Security.cipherSeed value by editing /app/Config/core.php
ê  The Model class is the bread and butter of CakePHP applications. By naming our model Post, CakePHP can automatically infer that this model will be used in the PostsController, and will be tied to a database table called posts.
ê  Actions often represent a single function or interface in an application.
ê  The link() method will generate an HTML link with the given title (the first parameter) and URL (the second parameter).
ê  $this->request->is() takes a single argument, which can be the request METHOD (get, put, post, delete) or some request identifier (ajax). It is not a way to check for specific posted data. For instance, $this->request->is(’book’) will not return true if book data was posted.
ê  Every CakePHP request includes a CakeRequest object which is accessible using
$this->request
ê  We use the FlashComponent’s FlashComponent::success() method to set a message to a session variable to be displayed on the page after redirection.
ê  FlashHelper::render() which displays the message and clears the corresponding session variable.
ê  To take advantage of the validation features, you’ll need to use CakePHP’s FormHelper in your views.
ê  to generate the opening tag for an HTML form $this->Form->create()
ê  If create() is called with no parameters supplied, it assumes you are building a form that submits via POST to the current controller’s add() action (or edit() action when id is included in the form data).
ê  The $this->Form->input() method is used to create form elements of the same name. The $this->Form->end() call generates a submit button and ends the form.
ê  Validation rules are defined in the model. The $validate array tells CakePHP how to validate data when the save() method is called
ê  Using postLink() will create a link that uses JavaScript to do a POST request to delete our post.
ê  CakePHP’s routing is found in /app/Config/routes.php.
ê  Controller class names are plural, CamelCased, and end in Controller. PeopleController and LatestArticlesController are both examples of conventional controller names.
ê  Model class names are singular and CamelCased. Person, BigPerson, and ReallyBigPerson are all examples of conventional model names.
ê  Table names corresponding456 to CakePHP models are plural and underscored. The underlying tables for the above mentioned models would be people, big_people, and really_big_people, respectively.
ê  View template files are named after the controller functions they display, in an underscored form. The getReady() function of the PeopleController class will look for a view template in /app/View/People/get_ready.ctp.
ê  Controllers callbacks:
• afterFilter(), executed after all controller logic, including the rendering of the view
• beforeFilter(), executed before any controller action logic
• beforeRender(), executed after controller logic, but before the view is rendered
ê  models have callbacks:
• beforeFind()
• afterFind()
• beforeValidate()
• afterValidate()
• beforeSave()
• afterSave()
• beforeDelete()
• afterDelete()
Chapter-3

ê  Model objects can be looked at as the first layer of interaction with any database you might be using for your application.

Chapter-4
ê  a controller is used to manage the logic around a single model
ê  Application’s controllers extend the AppController class, which in turn extends the core Controller class.
ê  The AppController class can be defined in /app/Controller/AppController.php and it should contain methods that are shared between all of your application’s controllers.
ê  CakePHP merges the following variables from the AppController into your application’s controllers:
• $components
• $helpers
• $uses
ê  The conventional view file name is the lowercased and underscored version of the action name.































0 comments:

Post a Comment