Upload
arafat-rahman
View
6.949
Download
1
Embed Size (px)
Citation preview
Web Application Development using MVC Framework Kohana
Arafat RahmanWeb Application Developer
Solution Arenahttp://arafatbd.net
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 components Simple routing structure
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 Configapplication/bootstrap.php
Database Config (cont.)application/config/database.php
Database Config (cont.)application/config/database.php
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) ;
Reading Database Recordsapplication/classes/controller/topic.php
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);
}
Reading Database Recordsapplication/view/list.php
Reading Database Recordsapplication/view/list.php
Reading Database Recordsapplication/view/list.php
Inserting New Recordsapplication/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 Recordshttp://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 ORMObject Relational Mapping (ORM)
application/classes/model/topic.php
class Model_Topic extends ORM { ...}
HMVCIn 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/wiki/doku.php
Questions ?Again, I am
Arafat Rahmanhttp://arafatbd.net