Options:

cakePHP Convention

In cakePHP we need to follow some rules defined by cake framework.we will go through this convention.First,we need to how to create,named model,view , controller and tables. it also provides global constants and functions.

Model Creation and Convention:

Convention:
1.Model class name should be singular and CamelCased(i.e every first letter of every word should be in upper case).Example: User,OnlineUser.


2. Model class page be 'user.php' or 'online_user.php'

3. This class file will be reside inside 'site_folder'->app->models



Syntax:
class User extends AppModel{
}

AppModel Class is defined inside the core cake directory.Model is related with table name.Each model has its associate table.one thing you need to remember that when you are creating a new table you also have to maintain some convention.


Table name Convention:

Table name will be plurals of its model name.

For 'User' model table name will be 'users' and OnlineUser table name will be online_users.



Controller Creation and Convention

Syntax:

Controller extends AppController {
function index(){
}

function signup(){
}
}

?>

Convention:
1. Controller class name should be plural and CamelCased(i.e every first letter of every word should be in upper case) and end with 'Controller' Keyword.Example: UsersController,OnlineUsersController.

2.
Controller class page will be 'user_controller.php' or 'online_users_controller.php'

3. This class file will be reside inside 'site_folder'->app->controllers



View Creation and Convention:

Convention:

1. View are actions names of it controller. for example UsersController has two action i.e:index and signup then it view files name will be index.thtml and signup.thml. Extension of these files may be .ctp.

2. These files will reside inside 'site_folder'->app->views.

3. For user you need to define a folder with plurals form inside view directory and inside this directory you need to save those view files.
i.e:'site_folder'->app->views->users.


We will discuss global constant and global functions later





Directory structure of cakePHP

At first you need to download the framework from http://cakephp.org/. Try to download the stable release version.Unpack the zip folder.

you will find three folder:

  1. app->application folder where all your code resides
  2. cake->cakePHP Core Framework[dont touch it]
  3. vendors->using for third party libraries

Now click on 'app' folder,see

cakePHP_folder_structure

there may be some other folders.lets forget it for now.

i am not going to show the other folder's inner structure.and also there are some other files inside the main folder.i.e index.php and .htaccess .these two files are important.


Please remind that when you are going to use any framewok, you need to maintain some convention.here in cake you see how the app folders shoul be.you also maintain some naming convention when creating model,views and controllers.we will discuss in details on the next post.

Cake PHP Fundamental

What is CakePHP:

it is not a food. ha ha ha.! it is a framework with MVC supported.When you are
developing large web applications or creating components that you will reuse in many applications,
you’ll find Cake to be a great help.Cake-PHP is evolving frameworks provide rapid application development tools to promote the adoption of particular programming languages.


Features of CakePHP:

Here are some features of Cake that make web application development with it easy
and fast:
1. it uses MVC(Model-View-Controller) framework for PHP.

2. Easy to install on most popular platform i.e UNX,Windows.

3. SEO friendly URl.

4. it uses easy templating system(with using helpers).

5. it has ready components email,authentication,localization,access controll,security, sessions, and request handling etc.

6.it has some useful ready helpers view helper,javascript helper,ajax helper etc.

7. it supports database connectivity like mysql,postgreSQL,Oracle,MSSql.

And many more we will discuss as we read it step by step.


Model View Controller(MVC) Design Pattern:


The aims of MVC design is to modularaize an application into three parts:


Model:
Represents Data for the application.

View:
Represents the presention i.e design view.

Controller:
Act as interpreter between model and view




Not clear?
Ok, let see what happen:

Input -> Processing -> Output

Controller -> Model -> View


OOPS! liite bit confuse???????

Don't worry buddy.i am here to washup your brain for cakePHP. Believe me its really a nice framework.when you will understand how powerfull it is,you will start hating the kind of hard coding paradigm.





Related topics

Your Ad Here