introduction mvc & cakephp
DESCRIPTION
TRANSCRIPT
![Page 1: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/1.jpg)
Hi!
Saturday, 19 January, 13
![Page 2: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/2.jpg)
I’m Myat Min Han aka Mike@mmhan
http://mmhan.net
Saturday, 19 January, 13
![Page 3: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/3.jpg)
Introduction to MVC & CakePHP
BarCamp Yangon 2013
Saturday, 19 January, 13
![Page 4: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/4.jpg)
I’m going to assume:You don’t know MVC and CakePHPYou know PHPYou (or want to) develop web applicationsYou want to deliver a project quickly.
Saturday, 19 January, 13
![Page 5: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/5.jpg)
MVC
Saturday, 19 January, 13
![Page 6: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/6.jpg)
To Show a random Joke
Saturday, 19 January, 13
![Page 7: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/7.jpg)
To Show a random Joke
Saturday, 19 January, 13
![Page 8: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/8.jpg)
1 - Browser Sends Request
To Show a random Joke
Saturday, 19 January, 13
![Page 9: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/9.jpg)
1 - Browser Sends Request
2 - Controller ask for a random Joke
To Show a random Joke
Saturday, 19 January, 13
![Page 10: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/10.jpg)
1 - Browser Sends Request
2 - Controller ask for a random Joke3 - Controller
Receives a random joke
To Show a random Joke
Saturday, 19 January, 13
![Page 11: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/11.jpg)
1 - Browser Sends Request
2 - Controller ask for a random Joke3 - Controller
Receives a random joke
4 - Controller sends the Joke to View
To Show a random Joke
Saturday, 19 January, 13
![Page 12: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/12.jpg)
1 - Browser Sends Request
2 - Controller ask for a random Joke3 - Controller
Receives a random joke
4 - Controller sends the Joke to View
5 - View shows the joke to browser.
To Show a random Joke
Saturday, 19 January, 13
![Page 13: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/13.jpg)
In a nutshell
Model - Business LogicController - Handling Transactions and requestsView - Presentation Layer
Saturday, 19 January, 13
![Page 14: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/14.jpg)
CakePHP
Saturday, 19 January, 13
![Page 15: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/15.jpg)
What is CakePHP?
Open-source MVC PHP Development Framework for web applications.Modeled after concepts of Ruby on RailsReleased in 2005
Saturday, 19 January, 13
![Page 16: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/16.jpg)
Creating a WebAppAwesome Random Joke
Saturday, 19 January, 13
![Page 17: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/17.jpg)
Download CakePHP Framework
Download from http://cakephp.org
Or git clone git://github.com/cakephp/cakephp.git random_jokes
Saturday, 19 January, 13
![Page 18: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/18.jpg)
Create a table in a new database
CREATE DATABASE `awesome_jokes`;
CREATE TABLE `jokes` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(150) DEFAULT NULL, `body` text, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`));
Saturday, 19 January, 13
![Page 19: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/19.jpg)
Configuring Databaseapp/Config/database.php
Saturday, 19 January, 13
![Page 20: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/20.jpg)
Checkout the sitehttp://localhost/random_jokes/
Saturday, 19 January, 13
![Page 21: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/21.jpg)
Let’s start baking
In Console (Or Command Prompt)
Saturday, 19 January, 13
![Page 22: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/22.jpg)
Follow the instructions
Saturday, 19 January, 13
![Page 23: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/23.jpg)
GeneratedList : http://localhost/random_jokes/jokes/
Saturday, 19 January, 13
![Page 24: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/24.jpg)
GeneratedNew: http://localhost/random_jokes/jokes/add/
Saturday, 19 January, 13
![Page 25: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/25.jpg)
GeneratedEdit: http://localhost/random_jokes/jokes/edit/<id>
Saturday, 19 January, 13
![Page 26: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/26.jpg)
GeneratedView: http://localhost/random_jokes/jokes/view/<id>
Saturday, 19 January, 13
![Page 27: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/27.jpg)
Blank jokes
Saturday, 19 January, 13
![Page 28: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/28.jpg)
Edit the Model fileapp/Model/Joke.php
Add validation rules
Saturday, 19 January, 13
![Page 29: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/29.jpg)
Give it a tryNew: http://localhost/random_jokes/jokes/add/
Saturday, 19 January, 13
![Page 30: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/30.jpg)
Showing Random Joke
Saturday, 19 January, 13
![Page 31: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/31.jpg)
Showing Random Jokeapp/Model/Joke.php
Add the business logic to model
Saturday, 19 January, 13
![Page 32: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/32.jpg)
Showing Random Jokeapp/Controller/JokesController.php
Add a new action (method) to JokesController class to create the a new url for your app
and retrieve random joke to show it on view http://localhost/random_jokes/jokes/random
Saturday, 19 January, 13
![Page 33: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/33.jpg)
Showing Random Jokeapp/View/Jokes/random.ctp
Create view file
Saturday, 19 January, 13
![Page 34: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/34.jpg)
Try it outhttp://localhost/random_jokes/jokes/random
Saturday, 19 January, 13
![Page 35: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/35.jpg)
Features
Saturday, 19 January, 13
![Page 36: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/36.jpg)
Features
Baking: Code GenerationConvention over ConfigurationActive RecordSecure by Default
Saturday, 19 January, 13
![Page 37: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/37.jpg)
And many other features
I18n
Caching
Access Control List
Authentication
Pagination
and lots of others...
Saturday, 19 January, 13
![Page 38: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/38.jpg)
Read More
About MVC - http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
CakePHP Official Site - http://cakephp.org
Cake Book - Reference material for all things CakePHP - http://book.cakephp.org
Plugins - http://plugins.cakephp.org/
Saturday, 19 January, 13
![Page 39: Introduction MVC & CakePHP](https://reader034.vdocuments.mx/reader034/viewer/2022052307/5494b32eac795925288b4dde/html5/thumbnails/39.jpg)
Thank You!
Saturday, 19 January, 13