cakephp file Structure

Source: Internet
Author: User
Tags php database

What about the development of a project that uses cakephp's files? If your project uses cake1.3.6, then you can refer to the following content according to my experience, will involve the folder: Configcontrollersmodelsservicesvendorsviewswebroot may also need to Logslocale We look at a folder in a folderConfigFolder/config/core.php core files, mainly through Configure::write () and define () define write global static variables/config/database.php database configuration file/config/routes.php Routing configuration file
ControllersFolder This folder under the main MVC in the C layer of code, that is, the control layer code, in the folder there is a folder called ComponentsThe files in the components file are stated as follows: Class Filtercomponent extends object{} The classes in this category are primarily public methods for some controller layers, The extraction of the code is declared in the controller file by defining the variable $this->components = array (' Filter ') to declare that the controller will use this component, called $this-> Filter->method () calls a controller, the Beforefilter () in each controller is called, and the Afterfilter () method is called after the call is complete. Therefore, you can define the Beforefilter () function in the App_controller of the base class, and perform the user identity check inside.ModelsThe folder is mainly MVC in the M layer of code, usually a database has a table, here need to have a corresponding model file models folder will also have a behaviors folder, which is the main lil bit model behavior to listen to the code, generally do not need to use. Model in the execution of Save, find, will be executed first BeforeSave, Beforefind, after the operation will be executed Aftersave, Afterfind function, so you can do in these functions of filter reorganization, the number of associated layers and so onServicesIf the component is the extraction of the public code of the controller layer, then the services layer is to extract the public service. For example, we will put the file export, verification code generation and other public background services in this folderVendorsFolder here will let us introduce the third-party PHP code, as well as we want to component of our own written PHP code such as we will be time-appropriate human, string to HTML tags and other functions here viewsFolder here is the V-layer code in MVC. A controller will have a folder in which the controller name is named, and the corresponding. CTP page (. CTP is actually the. html page) In addition, there will be aElementsfolder, which is the extraction of the public code for the view layer. For example, we will put front-end user avatar display, form and other foreground logic in the elements insideWebrootfolder is usually configured as the root directory of the Web site, which contains some front-end resource files, for example, there areCSS、Fonts、img、JSFolders are used to put the corresponding files and. index.php, is the site's only portal will also put Favicon.ico file, which is the Browser tab on the small icon corresponding to the picture

cakephp file Structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.