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
}
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
cakePHP Convention
- by sagar
- on Thursday, May 7, 2009
- AppController, AppModel, cakePHP, camelcase, class, controller, model, naming convention, php, tables, view
- 0 comments
- Digg
- Del.icio.us
Directory structure of cakePHP
- by sagar
- on Wednesday, May 6, 2009
- app, cake, cakePHP, mvc, naming convention, vendor
- 0 comments
- Digg
- Del.icio.us
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:
app->application folder where all your code resides
cake->cakePHP Core Framework[dont touch it]
vendors->using for third party libraries
Now click on 'app' folder,see
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
- by sagar
- on Monday, May 4, 2009
- access controll, ajax, authentication, component, controller, database, helper, javascript, model, mssql, mysql, oracle, postgresql, security, seo, sessions, template, unix, view, windows
- 0 comments
- Digg
- Del.icio.us
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.