Introduction to CakePHP By Aditya Mooley SANIsoft Technologies Pvt. Ltd.
Me <ul><li>Technical Manager with SANIsoft </li></ul><ul><li>Working with CakePHP since it started in 2005 </li></ul><ul><...
Cake! PHP! <ul><li>Framework written in PHP for PHP </li></ul><ul><li>Created by Larry E Masters (aka PhpNut) </li></ul><u...
Ok. But why CakePHP? <ul><li>MVC architecture </li></ul><ul><li>Convention over Configuration </li></ul><ul><li>Automatic ...
continued... <ul><li>Supports theming and Internationalization </li></ul><ul><li>Callback methods </li></ul><ul><li>Routin...
Cake Community <ul><li>Cake book -  http://book.cakephp.org </li></ul><ul><ul><li>Cake handbook with user comments </li></...
Convention over Configuration <ul><li>Follow the guidelines to name your -  </li></ul><ul><ul><li>Model, controller, view ...
Convention over Configuration <ul><li>Underscored filename and CamelCase class name </li></ul><ul><li>UserDetailsControlle...
Associations <ul><li>Ability to link models through relational mapping </li></ul><ul><li>HasOne </li></ul><ul><ul><li>User...
Components <ul><li>Built-in functionality for several commonly used tasks </li></ul><ul><li>Enhances controller functional...
Helpers <ul><li>Helper classes for views. </li></ul><ul><li>Paginator – Handles pagination and sorting </li></ul><ul><li>F...
Behaviors <ul><li>Adds more functionality to models without cluttering the model class </li></ul><ul><li>Can be shared by ...
DataSources <ul><li>Link between a model and its source of data </li></ul><ul><li>Mostly a database like MySQL, PostgreSQL...
Callback methods <ul><li>Methods called from within the framework before/after a specific action. </li></ul><ul><li>Used t...
Bake <ul><li>Cake bash script </li></ul><ul><li>Needs PHP CLI </li></ul><ul><li>Automatic code generation using database s...
References <ul><li>http://cakephp.org </li></ul><ul><li>http://book.cakephp.org </li></ul><ul><li>http://bakery.cakephp.or...
Thank you
Upcoming SlideShare
Loading in …5
×

Introduction to Cakephp

3,706 views

Published on

Published in: Technology
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
3,706
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
95
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Introduction to Cakephp

  1. 1. Introduction to CakePHP By Aditya Mooley SANIsoft Technologies Pvt. Ltd.
  2. 2. Me <ul><li>Technical Manager with SANIsoft </li></ul><ul><li>Working with CakePHP since it started in 2005 </li></ul><ul><li>Have one of the largest team working on CakePHP </li></ul><ul><li>Twitter - @adityamooley </li></ul>
  3. 3. Cake! PHP! <ul><li>Framework written in PHP for PHP </li></ul><ul><li>Created by Larry E Masters (aka PhpNut) </li></ul><ul><li>Follows MVC </li></ul><ul><li>Current stable version (1.2.5) runs on PHP 4 and 5 </li></ul><ul><li>Active community </li></ul><ul><li>Work already started on versions 1.3, 2 and 3 </li></ul>
  4. 4. Ok. But why CakePHP? <ul><li>MVC architecture </li></ul><ul><li>Convention over Configuration </li></ul><ul><li>Automatic code generation (aka bake) </li></ul><ul><li>Associations </li></ul><ul><li>Support for components/helpers/behaviors </li></ul><ul><li>Supports callback methods </li></ul>
  5. 5. continued... <ul><li>Supports theming and Internationalization </li></ul><ul><li>Callback methods </li></ul><ul><li>Routing </li></ul><ul><li>Gentle learning curve </li></ul><ul><li>and much more ... </li></ul>
  6. 6. Cake Community <ul><li>Cake book - http://book.cakephp.org </li></ul><ul><ul><li>Cake handbook with user comments </li></ul></ul><ul><li>Bakery - http://bakery.cakephp.org/ </li></ul><ul><ul><li>Communtity contribution to improve development with CakePHP </li></ul></ul><ul><li>CakeForge - http://www.cakeforge.org/ </li></ul><ul><ul><li>Hosting opensource projects built with CakePHP </li></ul></ul><ul><li>IRC channel - #cakephp @ irc.freenode.net </li></ul>
  7. 7. Convention over Configuration <ul><li>Follow the guidelines to name your - </li></ul><ul><ul><li>Model, controller, view files and classes </li></ul></ul><ul><ul><li>Class methods </li></ul></ul><ul><ul><li>Database tables, column names </li></ul></ul><ul><li>Automagic </li></ul><ul><li>Uniform system development </li></ul>
  8. 8. Convention over Configuration <ul><li>Underscored filename and CamelCase class name </li></ul><ul><li>UserDetailsController -> user_details_controller.php </li></ul><ul><li>Singular Model </li></ul><ul><li>Plural Controller </li></ul><ul><li>Plural database table name </li></ul><ul><li>Person Model, People Controller and people DB table </li></ul><ul><li>Primary key name - id </li></ul>
  9. 9. Associations <ul><li>Ability to link models through relational mapping </li></ul><ul><li>HasOne </li></ul><ul><ul><li>User hasOne Profile </li></ul></ul><ul><li>HasMany </li></ul><ul><ul><li>User hasMany Posts </li></ul></ul><ul><li>BelongsTo </li></ul><ul><ul><li>Post belongsTo User </li></ul></ul><ul><li>HasAndBelongsToMany (HABTM) </li></ul><ul><ul><li>Post has and belong to many Tags </li></ul></ul>
  10. 10. Components <ul><li>Built-in functionality for several commonly used tasks </li></ul><ul><li>Enhances controller functionality </li></ul><ul><li>Auth – User authentication system </li></ul><ul><li>Acl – Access control list </li></ul><ul><li>Email – Send mail using PHP's mail function and smtp </li></ul><ul><li>Security – Get rid of CSRF and form tampering </li></ul><ul><li>Possibility to write custom components </li></ul>
  11. 11. Helpers <ul><li>Helper classes for views. </li></ul><ul><li>Paginator – Handles pagination and sorting </li></ul><ul><li>Form – Easier creation of form elements </li></ul><ul><li>HTML – Creates uniform and XHTML tags </li></ul><ul><li>RSS – Makes generation of RSS feeds easy </li></ul><ul><li>many more ... </li></ul>
  12. 12. Behaviors <ul><li>Adds more functionality to models without cluttering the model class </li></ul><ul><li>Can be shared by multiple models </li></ul><ul><li>Can be attached to model using $actsAs or even on the fly </li></ul><ul><li>Examples – upload, slug, tags </li></ul>
  13. 13. DataSources <ul><li>Link between a model and its source of data </li></ul><ul><li>Mostly a database like MySQL, PostgreSQL, etc. </li></ul><ul><li>Possibility to connect to unconventional sources of data like Salesforce and other REST APIs </li></ul><ul><li>More examples: Twitter, Paypal, etc </li></ul>
  14. 14. Callback methods <ul><li>Methods called from within the framework before/after a specific action. </li></ul><ul><li>Used to execute special logic before Cake's default operation. </li></ul><ul><li>Controller callbacks </li></ul><ul><ul><li>beforeFilter, afterFilter, beforeRender </li></ul></ul><ul><li>Model callbacks </li></ul><ul><ul><li>BeforeFind, afterFind, beforeValidate, beforeSave, afterSave, etc. </li></ul></ul>
  15. 15. Bake <ul><li>Cake bash script </li></ul><ul><li>Needs PHP CLI </li></ul><ul><li>Automatic code generation using database schema </li></ul><ul><li>Model with validations </li></ul><ul><li>Controller with CRUD actions </li></ul><ul><li>Necessary views for user interaction </li></ul>
  16. 16. References <ul><li>http://cakephp.org </li></ul><ul><li>http://book.cakephp.org </li></ul><ul><li>http://bakery.cakephp.org </li></ul><ul><li>http://cakeforge.org </li></ul><ul><li>http://www.sanisoft.com/blog </li></ul>
  17. 17. Thank you

×