003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02

2,435 views

Published on

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

  • Be the first to like this

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

No notes for slide

003 web-apps-using-kohana-arafat-rahman-101107191139-phpapp02

  1. 1. Web Application Developmentusing MVC Framework Kohana Arafat Rahman Web Application Developer Solution Arena http://arafatbd.net
  2. 2. Framework ?Provides Generic functionality Some key features Reusable Well-defined Specialized by user
  3. 3. Why Kohana (KO3) Its MVC Its HMVC Very fast framework Strict PHP 5.2 - OOP and extremely DRY Many common components Simple routing structure
  4. 4. MVC ?Model-View-Controller
  5. 5. MVC
  6. 6. HMVC ?Hierarchical Model View Controller
  7. 7. MVC and HMVC
  8. 8. Setting up Kohana (KO3)
  9. 9. Setting up Kohana
  10. 10. Configurationapplication/bootstrap.phpKohana::init(array(base_url => /kohana/,));
  11. 11. Configuration (cont.)Delete /install.php
  12. 12. Requesting a Controller/index.php/<controller>/<action>example:/index.php/topic/view/123
  13. 13. Hello, world!
  14. 14. Hello, world! (cont.)http://localhost/kohana/index.php/welcome
  15. 15. Hide index.phpHow to hide index.phphttp://kerkness.ca/wiki/doku.php? id=removing_the_index.php
  16. 16. Hello, world! (cont.)http://localhost/kohana/welcome
  17. 17. Database Configapplication/bootstrap.php
  18. 18. Database Config (cont.)application/config/database.php
  19. 19. Database Config (cont.)application/config/database.php
  20. 20. Create Table: topicsCREATE TABLE `kohana`.`topics` (`topic_id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,`title` VARCHAR( 250 ) NOT NULL ,`description` TEXT NOT NULL ,`date` DATETIME NOT NULL) ;
  21. 21. Reading Database Recordsapplication/classes/controller/topic.php
  22. 22. Reading Database Recordsapplication/classes/controller/topic.phptry { $data[topics] = DB::select() ->from(topics) ->order_by(date, "DESC") ->execute() ->as_array(); $this->request->response = View::factory(list, $data);}
  23. 23. Reading Database Recordsapplication/view/list.php
  24. 24. Reading Database Recordsapplication/view/list.php
  25. 25. Reading Database Recordsapplication/view/list.php
  26. 26. Inserting New Recordsapplication/classes/controller/topic.phphttp://localhost/kohana/topic/new_topic
  27. 27. Inserting New Records (cont.)http://localhost/kohana/topic/new_topic
  28. 28. Inserting New Records (cont.)application/classes/controller/topic.php
  29. 29. Inserting New Records (cont.)application/classes/controller/topic.php
  30. 30. Inserting New Records (cont.)application/classes/controller/topic.php
  31. 31. Update Recordshttp://localhost/kohana/topic/index
  32. 32. Update Records (cont.)application/classes/controller/topic.php
  33. 33. Update Records (cont.)application/classes/controller/topic.php
  34. 34. Update Records (cont.)http://localhost/kohana/topic/edit/1
  35. 35. Update Records (cont.)application/classes/controller/topic.php
  36. 36. Update Records (cont.)application/classes/controller/topic.php
  37. 37. Model and ORM Object Relational Mapping (ORM)application/classes/model/topic.phpclass Model_Topic extends ORM { ...}
  38. 38. HMVCIn a View<?php echo $content;?><br/><?php echo Request::factory(topic/featured) ->execute()->response;?>
  39. 39. HMVC (cont.)In a Controller$data[featured] = Request::factory(topic/featured) ->execute()->response;
  40. 40. References Kohana Documentationhttp://kohanaframework.org/documentation Unofficial documentaionhttp://kerkness.ca/wiki/doku.php
  41. 41. Questions ?Again, I amArafat Rahmanhttp://arafatbd.net

×