Published on

CakePHP is a nice way of using MVC architecture in you PHP environment. Looking through this presentation you'll get introduced to MVC and get some start up code examples for you to explore.

Published in: Education
No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. CakePHP<br />Rapid Development Framework<br />
  2. 2. Why CakePHP?<br />MVC<br />DRY<br />ORM<br />Convention over Configuration<br />Architecture for developing, maintaining, and deploying applications<br />
  3. 3. Basic Features<br /><ul><li>Model, View, Controller Architecture
  4. 4. Application Scaffolding
  5. 5. Code generation via Bake
  6. 6. Helpers for HTML, Forms, Pagination, AJAX, Javascript, XML, RSS and more
  7. 7. Access Control Lists and Authentication
  8. 8. Simple yet extensive validation of model data</li></li></ul><li>Basic Features cont.<br /><ul><li>Router for mapping urls and handling extensions
  9. 9. Security, Session, and RequestHandler Components
  10. 10. Utility classes for working with Files, Folders, Arrays and more</li></li></ul><li>What is Cake & Why?<br /><ul><li>Free & Open Source.
  11. 11. Rapid Development Frame Work Based Around MVC Methodology.
  12. 12. Templating, Helpers, Components. In short reusable code!
  13. 13. Built in Email, Cookie, Security, Session & Request Handling Components.
  14. 14. Caching.</li></li></ul><li>Modle View Controller<br /><ul><li>Model View Controller design patter is based upon separating your code into three sections.
  15. 15. The Model represents the application data.
  16. 16. The View renders a presentation of the model data.
  17. 17. The Controller handles & routes requests made by the client.</li></li></ul><li>Modle View Controller<br />
  18. 18. Basic Principles of CakePHP<br /><ul><li>Conventions
  19. 19. Extensions
  20. 20. Controller Extensions - Components
  21. 21. View Extensions - Helpers
  22. 22. Model Extensions - Behaviors
  23. 23. CSS/HTML - Elements</li></li></ul><li>How does it work?<br /><br />
  24. 24. Use Bake<br />The CakePHP Bake console can create any of CakePHP’s basic ingredients: models, views and controllers. And I am not just talking skeleton classes: Bake can create a fully functional application in just a few minutes.<br />
  25. 25. Use Bake<br />In order to use the bakery, locate the cake bash script in your path and make it executable (make sure you have access rights to the path, using sudo -i or equivalent):<br />$ cp cake/console/cake* /usr/local/bin/$ mv cake /usr/cake$ chmod 755 /usr/local/bin/cake<br />Using the Bakery<br />$ cake –help<br />[..]<br /> acl [CORE] i18n [CORE] <br /> api [CORE] schema [CORE] <br /> bake [CORE] testsuite [CORE] <br /> console [CORE] <br />
  26. 26. Let us create the tables for our application which will be a jobs board:<br />CREATE TABLEIF NOT EXISTS `categories` (`id` int(11) NOT NULL AUTO_INCREMENT,`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM;CREATE TABLEIF NOT EXISTS `jobs` (`id` int(11) NOT NULL AUTO_INCREMENT,`category_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,`body` text COLLATE utf8_unicode_ci,`company` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,`job_type` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,`created` datetime DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM;CREATE TABLEIF NOT EXISTS `users` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`pass` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`location` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,`address` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,`email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,`web` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM;<br />
  27. 27. Enter this code in your command prompt<br />$ cd /var/www/newcakeapp$ cake bake all[..](Press) 1 (for categories)<br />Bake generated the links for List jobs and New job, but it is not working at this moment as we did not bake files for jobs table yet.<br />Repeat cake bake all as necessary.<br />Now, point your browser to your categories controller. Go ahead and try to add an empty category. Validation is working, but messages need some tweaking. Notice how CakePHP added a Pagination below the table with Categories. Nice. And if you click on column names, data is sorted by that column! <br />
  28. 28. Typical Request<br />
  29. 29. Controllers pass args to model<br />$this->set(‘view_var’, $controller_var);<br />
  30. 30. Built-in Helpers<br />Reusable code (DRY) accessible to any view.<br />Paginator <br />RSS <br />Session <br />Text<br />Time<br /><ul><li>AJAX
  31. 31. Cache
  32. 32. Form*
  33. 33. HTML*
  34. 34. Javascript*
  35. 35. Number
  36. 36. Paginator </li></li></ul><li>Built-in Components<br />Reusable code (DRY) accessible to any controller.<br /><ul><li>Acl
  37. 37. Auth
  38. 38. Session
  39. 39. RequestHandler
  40. 40. Security
  41. 41. Email
  42. 42. Cookie</li></li></ul><li>Directories<br /><ul><li>Config - Holds the application configuration files.
  43. 43. Database connection
  44. 44. Bootstrap
  45. 45. Core
  46. 46. Controllers - Contains your application controller & components.
  47. 47. Models - Contains your application models, behaviors & data sources.</li></li></ul><li>Directories<br /><ul><li>Tmp - This is where CakePHP stores temporary data.
  48. 48. Vendors - Third Party Libraries.
  49. 49. Views - What the user sees.
  50. 50. Webroot - Contains CSS/JS/Flash/Etc Files</li></li></ul><li>Resources<br /><ul><li>
  51. 51.
  52. 52. #cakephp on
  53. 53.
  54. 54.
  55. 55.
  56. 56.</li>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.