3 introduction-php-mvc-cakephp-m3-getting-started-slides
TRANSCRIPT
![Page 1: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/1.jpg)
Getting Started
Jill Gundersen
![Page 2: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/2.jpg)
Getting Started
CakePHP Folder Structure CakePHP Naming Rules
There are a set of rules when naming your files, classes and functions.
![Page 3: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/3.jpg)
Folder Structure
Contents of CakePHP Directory
![Page 4: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/4.jpg)
Inside the App Folder
![Page 5: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/5.jpg)
Inside the App Folder
Config - Contains a few of the configuration files such as: database connection, core configuration, bootstrapping.
![Page 6: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/6.jpg)
Inside the App Folder
Console - Console command and console tasks are located in this folder.
![Page 7: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/7.jpg)
Inside the App Folder
Controller - Contains your application’s controllers and components.
![Page 8: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/8.jpg)
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.
![Page 9: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/9.jpg)
Inside the App Folder
Locale - Stores the string files needed for internationalization.
![Page 10: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/10.jpg)
Inside the App Folder
Model - Contains your application's models, behaviors, and data sources.
![Page 11: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/11.jpg)
Inside the App Folder
Plugin - This is where your plugin packages will be stored.
![Page 12: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/12.jpg)
Inside the App Folder
Test - This directory contains your test cases and test fixtures for your application.
![Page 13: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/13.jpg)
Inside the App Folder
tmp - Temporary data will be stored here.
![Page 14: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/14.jpg)
Inside the App Folder
Vendor - Third-party libraries and classes are placed here.
![Page 15: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/15.jpg)
Inside the App Folder
View - All presentation files are located here. These include views, elements, helpers, layouts, and error pages.
![Page 16: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/16.jpg)
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.
![Page 17: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/17.jpg)
Naming Controllers
CamelCase End with word “Controller” Pluralized Examples
DessertsController.php LatestRecipesController.php
Located in the Controller Folder /app/Controller/DessertsController.php
![Page 18: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/18.jpg)
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()
![Page 19: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/19.jpg)
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
![Page 20: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/20.jpg)
Naming Models
Singular CamelCase Examples
Pastry.php PuffPastry.php
Located in the Model Folder /app/Model/Pastry.php
![Page 21: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/21.jpg)
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
![Page 22: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/22.jpg)
Naming Database Table Fields
Primary Key id
All Lowercase Separate words with underscore Examples
title cake_name
![Page 23: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/23.jpg)
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
![Page 24: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/24.jpg)
Help Wanted
Not Sure? CakePHP provides a web site to help with naming conventions. http://inflector.cakephp.org/
![Page 25: 3 introduction-php-mvc-cakephp-m3-getting-started-slides](https://reader034.vdocuments.site/reader034/viewer/2022052505/554f5869b4c905b9508b5225/html5/thumbnails/25.jpg)
Summary
Folder Structure Naming Conventions
Models Controllers
Controller Functions
Views Database
Table Names Field Names Foreign Keys Many to Many Tables