Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • CakePHP Naming Conventions

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 43
    Comment on it

    Hello Readers, this blog tutorial will explain how to use naming convention in CakePHP.
    CakePHP have its own naming convention standards to be used during PHP application development.
    If you want to create application using CakePHP, first you will need to create following files:


    1. file to define the model,

    2 file to define the controller,

    3 files to represent output called presentation files or view files.

    so, while creating model, controller & view files you have to follow CakePHP standards naming conventions

    Table:
    Table names corresponding to models are plural and underscored.

     

    Controller:
    Controller classnames are plural, CamelCased, and end in Controller.
    UsersController and PostsController are both examples of cakephp conventional names.

     

    Model:
    Model classnames are singular and CamelCased. User, Post are both examples of conventional model names.

    For Example: Table Name-> "findnerds"
    CakePHP naming conventions for model, view, and controller elements.

     

    Model
      filename  =Findnerd.php
      classname =Findnerd
      directory = app/models

     

    View
      filename  = (same as the action name in the controller)
      extension = .ctp (the filename extension)
      directory = app/views/Findnerds

     

    Controller
      filename  = Findnerdscontroller.php
      classname = FindnerdsController
      directory = app/controllers

     

    Another Example: tables Names-> cities, users_properties
    Controllers should be: CitiesController.php, UsersPropertiesController.php
    Models should be: Administrator.php, City.php, UserProperty.php

 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: