Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Differentiate between Component, Behavior, and Helper in Cakephp.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 658
    Comment on it

    These all extend existing CakePHP functionality so they are almost similar but differ on what they extend from the existing folder.


    The Component is used here in the controller it will used as a packages of logic and function and these are shared between controllers. The User can create their own components as well.

    The Behaviors are used to change the  behaves defined in the model. It allow user to separate and reuse logic that creates a type of behavior, and User can use this without requiring inheritance.

    The function Helper contain  logic that is used in views, elements, or layouts for making better presentation and to specify an action.

    For Example:

    1. A Component is used to extend a Controller
          

     Syntax:

        public $components = array(Emails, ImageUploader, Sms);

    2.A Behavior is used to extend a Model.


    Syntax:

    	 public $actsAs = array('Tree');

    3.A Helper is used to extend a View.


    Syntax:

         public $helpers = array('Form', 'Html', 'Js', 'Time');
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: