Successfully reported this slideshow.
Web Application Development
using MVC Framework Kohana
Arafat Rahman
Web Application Developer
Solution Arena
http://arafa...
Framework ?
Provides

Generic
functionality

Some key features

Reusable

Well-defined

Specialized by user
Why Kohana (KO3)

Its MVC

Its HMVC

Very fast framework

Strict PHP 5.2 - OOP and extremely DRY

Many common compone...
MVC ?
Model-View-Controller
MVC
HMVC ?
Hierarchical Model View Controller
MVC and HMVC
Setting up Kohana (KO3)
Setting up Kohana
Configuration
application/bootstrap.php
Kohana::init(array(
'base_url' => '/kohana/',
));
Configuration (cont.)
Delete

/install.php
Requesting a Controller
/index.php/<controller>/<action>
example:
/index.php/topic/view/123
Hello, world!
Hello, world! (cont.)
http://localhost/kohana/index.php/welcome
Hide index.php
How to hide index.php
http://kerkness.ca/wiki/doku.php?
id=removing_the_index.php
Hello, world! (cont.)
http://localhost/kohana/welcome
Database Config
application/bootstrap.php
Database Config (cont.)
application/config/database.php
Database Config (cont.)
application/config/database.php
Create Table: topics
CREATE TABLE `kohana`.`topics` (
`topic_id` INT( 11 ) NOT NULL
AUTO_INCREMENT PRIMARY KEY ,
`title` V...
Reading Database Records
application/classes/controller/topic.php
Reading Database Records
application/classes/controller/topic.php
try {
$data['topics'] = DB::select()
->from('topics')
->...
Reading Database Records
application/view/list.php
Reading Database Records
application/view/list.php
Reading Database Records
application/view/list.php
Inserting New Records
application/classes/controller/topic.php
http://localhost/kohana/topic/new_topic
Inserting New Records (cont.)
http://localhost/kohana/topic/new_topic
Inserting New Records (cont.)
application/classes/controller/topic.php
Inserting New Records (cont.)
application/classes/controller/topic.php
Inserting New Records (cont.)
application/classes/controller/topic.php
Update Records
http://localhost/kohana/topic/index
Update Records (cont.)
application/classes/controller/topic.php
Update Records (cont.)
application/classes/controller/topic.php
Update Records (cont.)
http://localhost/kohana/topic/edit/1
Update Records (cont.)
application/classes/controller/topic.php
Update Records (cont.)
application/classes/controller/topic.php
Model and ORM
Object Relational Mapping (ORM)
application/classes/model/topic.php
class Model_Topic extends ORM {
...
}
HMVC
In a View
<?php echo $content;?><br/>
<?php echo
Request::factory('topic/featured')
->execute()->response;
?>
HMVC (cont.)
In a Controller
$data['featured'] =
Request::factory('topic/featured')
->execute()->response;
References

Kohana Documentation
http://kohanaframework.org/documentation

Unofficial documentaion
http://kerkness.ca/wi...
Questions ?
Again, I am
Arafat Rahman
http://arafatbd.net
Upcoming SlideShare
Loading in …5
×

Web Application Development using MVC Framework Kohana

7,142 views

Published on

I tried to show key features of Kohana (KO3) and CRUD using Kohana.

Published in: Technology
  • Be the first to comment

Web Application Development using MVC Framework Kohana

  1. 1. Web Application Development using 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. Configuration application/bootstrap.php Kohana::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.php How to hide index.php http://kerkness.ca/wiki/doku.php? id=removing_the_index.php
  16. 16. Hello, world! (cont.) http://localhost/kohana/welcome
  17. 17. Database Config application/bootstrap.php
  18. 18. Database Config (cont.) application/config/database.php
  19. 19. Database Config (cont.) application/config/database.php
  20. 20. Create Table: topics CREATE 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 Records application/classes/controller/topic.php
  22. 22. Reading Database Records application/classes/controller/topic.php try { $data['topics'] = DB::select() ->from('topics') ->order_by('date', "DESC") ->execute() ->as_array(); $this->request->response = View::factory('list', $data); }
  23. 23. Reading Database Records application/view/list.php
  24. 24. Reading Database Records application/view/list.php
  25. 25. Reading Database Records application/view/list.php
  26. 26. Inserting New Records application/classes/controller/topic.php http://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 Records http://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.php class Model_Topic extends ORM { ... }
  38. 38. HMVC In 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 Documentation http://kohanaframework.org/documentation  Unofficial documentaion http://kerkness.ca/wiki/doku.php
  41. 41. Questions ? Again, I am Arafat Rahman http://arafatbd.net

×