Introduction MVC & CakePHP

3,632 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,632
On SlideShare
0
From Embeds
0
Number of Embeds
842
Actions
Shares
0
Downloads
49
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Introduction MVC & CakePHP

  1. 1. Hi!Saturday, 19 January, 13
  2. 2. I’m Myat Min Han aka Mike @mmhan http://mmhan.netSaturday, 19 January, 13
  3. 3. Introduction to MVC & CakePHP BarCamp Yangon 2013Saturday, 19 January, 13
  4. 4. I’m going to assume: You don’t know MVC and CakePHP You know PHP You (or want to) develop web applications You want to deliver a project quickly.Saturday, 19 January, 13
  5. 5. MVCSaturday, 19 January, 13
  6. 6. To Show a random JokeSaturday, 19 January, 13
  7. 7. To Show a random JokeSaturday, 19 January, 13
  8. 8. To Show a random Joke 1 - Browser Sends RequestSaturday, 19 January, 13
  9. 9. To Show a random Joke 1 - Browser Sends Request 2 - Controller ask for a random JokeSaturday, 19 January, 13
  10. 10. To Show a random Joke 1 - Browser Sends Request 2 - Controller ask for a random Joke 3 - Controller Receives a random jokeSaturday, 19 January, 13
  11. 11. To Show a random Joke 1 - Browser Sends Request 2 - Controller ask for a random Joke 4 - Controller sends the Joke to View 3 - Controller Receives a random jokeSaturday, 19 January, 13
  12. 12. To Show a random Joke 5 - View shows the joke to browser. 1 - Browser Sends Request 2 - Controller ask for a random Joke 4 - Controller sends the Joke to View 3 - Controller Receives a random jokeSaturday, 19 January, 13
  13. 13. In a nutshell Model - Business Logic Controller - Handling Transactions and requests View - Presentation LayerSaturday, 19 January, 13
  14. 14. CakePHPSaturday, 19 January, 13
  15. 15. What is CakePHP? Open-source MVC PHP Development Framework for web applications. Modeled after concepts of Ruby on Rails Released in 2005Saturday, 19 January, 13
  16. 16. Creating a WebApp Awesome Random JokeSaturday, 19 January, 13
  17. 17. Download CakePHP Framework Download from http://cakephp.org Or git clone git://github.com/cakephp/cakephp.git random_jokesSaturday, 19 January, 13
  18. 18. 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
  19. 19. Configuring Database app/Config/database.phpSaturday, 19 January, 13
  20. 20. Checkout the site http://localhost/random_jokes/Saturday, 19 January, 13
  21. 21. Let’s start baking In Console (Or Command Prompt)Saturday, 19 January, 13
  22. 22. Follow the instructionsSaturday, 19 January, 13
  23. 23. Generated List : http://localhost/random_jokes/jokes/Saturday, 19 January, 13
  24. 24. Generated New: http://localhost/random_jokes/jokes/add/Saturday, 19 January, 13
  25. 25. Generated Edit: http://localhost/random_jokes/jokes/edit/<id>Saturday, 19 January, 13
  26. 26. Generated View: http://localhost/random_jokes/jokes/view/<id>Saturday, 19 January, 13
  27. 27. Blank jokesSaturday, 19 January, 13
  28. 28. Edit the Model file app/Model/Joke.php Add validation rulesSaturday, 19 January, 13
  29. 29. Give it a try New: http://localhost/random_jokes/jokes/add/Saturday, 19 January, 13
  30. 30. Showing Random JokeSaturday, 19 January, 13
  31. 31. Showing Random Joke app/Model/Joke.php Add the business logic to modelSaturday, 19 January, 13
  32. 32. Showing Random Joke app/Controller/JokesController.php Add a new action (method) to JokesController class to create the a new url for your app http://localhost/random_jokes/jokes/random and retrieve random joke to show it on viewSaturday, 19 January, 13
  33. 33. Showing Random Joke app/View/Jokes/random.ctp Create view fileSaturday, 19 January, 13
  34. 34. Try it out http://localhost/random_jokes/jokes/randomSaturday, 19 January, 13
  35. 35. FeaturesSaturday, 19 January, 13
  36. 36. Features Baking: Code Generation Convention over Configuration Active Record Secure by DefaultSaturday, 19 January, 13
  37. 37. And many other features I18n and lots of others... Caching Access Control List Authentication Email PaginationSaturday, 19 January, 13
  38. 38. 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
  39. 39. Thank You!Saturday, 19 January, 13

×