Freelance Jobs Freelance Jobs

Tuesday, April 27, 2010

Introduction to CakePHP

CakePHP is open source web developing framework of PHP for creating web applications. It provides programmer a foundational structure to create a web applications.

CakePHP is based on the MVC architecture to create a web applications. It means that business logic(Model), user action(controller) and data presentation to user(View) are different from each other.

Controller: Controller contains the logic of user's application. The different functionality are contained by each controller. It used models to retrieve data from database or save data to database. It also set variable which is used to render data in view file.

Models: Models directly connected to database tables. It retrieve data from database and send it to controller, get data from controller and save it to database. Models behave like medium between controller and database tables. The models is interact with controller but not interact with view.

Views: view is used to present data to end user. It gets the variable from controller and display it to end user. View contains layout, element, for data presentation but no logic to retrieve data from database.

Since cakephp is open source so any body can download it from www.cakephp.org and install it and can work. There is no need of license fee to work in cakephp. You have to knowledge of PHP to start work in cakephp.


Folder Structure

When we download the cakephp from site, it is a zip file. After extracting it, the following files and folder you should see:

  1. app
  2. cake
  3. vendors
  4. .htaccess
  5. index.php
  6. README

All the applications file of the user are placed in app folder.
All the file of cakephp are placed in cake folder.
The third party files are placed in vendors folder.


App folder:

The app folder contains following files and folder:

config :
The config folder contains the following files and folder

database.php : It is used to database configuration.

routes.php : It is used to set up routes to user controllers and their actions. The routes is a mechanism which allow user to freely connect different urls to chosen controllers and their actions.

bootstrap.php: This file is automatically loaded by the app/webroot/index.php file after the core bootstrap.php. This file is used to include or require any files in user's application. This is application wide file that is used to load any function that is not used within a class define.

core.php : It is used to configure core behavior of cake.

controllers: It contains the controller of the user's application.

locale: It contains the files that is used for internationalization.

models: It contains models, behavior of the user's application

plugins: It contains plugin package of user's application.

tmp: It contains temporary file of user's application. This folder is used to store model descriptions,
log, caching, session information.

vendors: It contains the third party files to used in user's application. The file placed in this folder can be accessed in application using App::import('vendors','name');. The vendors folder is placed also at top level. The top level vendors folder contains third party file for user's all application but if user is creating multiple applications then he can placed third party files in this folder to use for specific application.

views: It contains view file, layout file, elements, error page of user's application.

webroot: This folder serve as document root for user's application. It contians css stylesheet, javascript file, image for user's application.

No comments:

Post a Comment