Getting Started
Jill Gundersen
Getting Started
 CakePHP Folder Structure
 CakePHP Naming Rules


There are a set of rules when naming your files, clas...
Folder Structure
 Contents of CakePHP Directory
Inside the App Folder
Inside the App Folder

Config Contains a few of the configuration files such as: database
connection, core configuration, ...
Inside the App Folder

Console Console command and console tasks are located in
this folder.
Inside the App Folder

Controller Contains your application’s controllers and
components.
Inside the App Folder

Lib Contains first-party libraries that do not come from
third-parties or external vendors. Keeps y...
Inside the App Folder

Locale Stores the string files needed for internationalization.
Inside the App Folder

Model Contains your application's models, behaviors, and
data sources.
Inside the App Folder

Plugin This is where your plugin packages will be stored.
Inside the App Folder

Test This directory contains your test cases and test
fixtures for your application.
Inside the App Folder

tmp Temporary data will be stored here.
Inside the App Folder

Vendor Third-party libraries and classes are placed here.
Inside the App Folder

View All presentation files are located here. These include
views, elements, helpers, layouts, and ...
Inside the App Folder

webroot This folder will serve as the document root of our
application in a production setup. CSS, ...
Naming Controllers





CamelCase
End with word “Controller”
Pluralized
Examples



DessertsController.php
LatestRec...
Naming Controller Functions
 camelCased (lowercase first word)
 No Underscores
 Examples



cakes()
favoriteCookies()...
Naming Views





Named After the Controller Functions They Display
All Lowercase
Underscore to Separate Multiple Word...
Naming Models
 Singular
 CamelCase
 Examples



Pastry.php
PuffPastry.php

 Located in the Model Folder


/app/Mode...
Naming Database Tables






Table Names Correspond to the Model Names
Pluralized
All Lowercase
Underscore to Separat...
Naming Database Table Fields
 Primary Key


id

 All Lowercase
 Separate words with underscore
 Examples



title
c...
Naming When Joining Tables
 Foreign Keys



Singular name of the table followed by _id
Examples



cakes table -> cak...
Help Wanted
 Not Sure?



CakePHP provides a web site to help with naming conventions.
http://inflector.cakephp.org/
Summary
 Folder Structure
 Naming Conventions



Models
Controllers





Controller Functions

Views
Database


...
Upcoming SlideShare
Loading in …5
×

3 introduction-php-mvc-cakephp-m3-getting-started-slides

4,441 views

Published on

Published in: Education, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,441
On SlideShare
0
From Embeds
0
Number of Embeds
797
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

3 introduction-php-mvc-cakephp-m3-getting-started-slides

  1. 1. Getting Started Jill Gundersen
  2. 2. Getting Started  CakePHP Folder Structure  CakePHP Naming Rules  There are a set of rules when naming your files, classes and functions.
  3. 3. Folder Structure  Contents of CakePHP Directory
  4. 4. Inside the App Folder
  5. 5. Inside the App Folder Config Contains a few of the configuration files such as: database connection, core configuration, bootstrapping.
  6. 6. Inside the App Folder Console Console command and console tasks are located in this folder.
  7. 7. Inside the App Folder Controller Contains your application’s controllers and components.
  8. 8. Inside the App Folder Lib Contains first-party libraries that do not come from third-parties or external vendors. Keeps your libraries separate from third party vendors.
  9. 9. Inside the App Folder Locale Stores the string files needed for internationalization.
  10. 10. Inside the App Folder Model Contains your application's models, behaviors, and data sources.
  11. 11. Inside the App Folder Plugin This is where your plugin packages will be stored.
  12. 12. Inside the App Folder Test This directory contains your test cases and test fixtures for your application.
  13. 13. Inside the App Folder tmp Temporary data will be stored here.
  14. 14. Inside the App Folder Vendor Third-party libraries and classes are placed here.
  15. 15. Inside the App Folder View All presentation files are located here. These include views, elements, helpers, layouts, and error pages.
  16. 16. Inside the App Folder webroot This folder will serve as the document root of our application in a production setup. CSS, JavaScript, and images are also stored in this folder.
  17. 17. Naming Controllers     CamelCase End with word “Controller” Pluralized Examples   DessertsController.php LatestRecipesController.php  Located in the Controller Folder  /app/Controller/DessertsController.php
  18. 18. Naming Controller Functions  camelCased (lowercase first word)  No Underscores  Examples   cakes() favoriteCookies()  Protected/Private functions   Any function you don’t want accessed directly from the web should be prefixed with _ Example  _findLatestRecipe()
  19. 19. Naming Views     Named After the Controller Functions They Display All Lowercase Underscore to Separate Multiple Words Examples   cakes() -> cakes.ctp favoriteCookies () -> favorite_cookies.ctp  Located in the Controller Named Folder of the View Folder   Create a folder inside the Views folder and name it the name of the controller minus the “Controller” portion. /app/View/Desserts/favorite_cookies.ctp
  20. 20. Naming Models  Singular  CamelCase  Examples   Pastry.php PuffPastry.php  Located in the Model Folder  /app/Model/Pastry.php
  21. 21. Naming Database Tables      Table Names Correspond to the Model Names Pluralized All Lowercase Underscore to Separate Multiple Words Examples   Pastry.php -> pastries PuffPastry.php -> puff_pastries
  22. 22. Naming Database Table Fields  Primary Key  id  All Lowercase  Separate words with underscore  Examples   title cake_name
  23. 23. Naming When Joining Tables  Foreign Keys   Singular name of the table followed by _id Examples   cakes table -> cake_id puff_pastries -> puff_pastry_id  HABTM – Has and Belongs To Many (Many to Many)       Named after the tables Tables are in alphabetical order Underscore between the two table names Pluralized All Lowercase Example  cakes_ingredients
  24. 24. Help Wanted  Not Sure?   CakePHP provides a web site to help with naming conventions. http://inflector.cakephp.org/
  25. 25. Summary  Folder Structure  Naming Conventions   Models Controllers    Controller Functions Views Database     Table Names Field Names Foreign Keys Many to Many Tables

×