Skip to content
saturngod edited this page Feb 2, 2012 · 6 revisions

Tutorial

Let start sample tutorial to understand routing system , Controller , Model and View.

  • Download the latest stable code.
  • unzip the folder
  • add all the files to your_localhost_path/ava

Config

config in system/config/development.php

change base_url and home_controller

const base_url="http://localhost/Ava";
const home_controller = 'home';

Create Controller

  • Delete all files in system/application/controller
  • Delete all files in system/application/model
  • Delete all files in system/application/view
  • Create home.php in system/application/controller

add following text in system/application/controller/home.php

<?php

class homeController extends Ava_Controller {
	
	function index()
	{
		
    }
}

Add Routing

<?php

class homeController extends Ava_Controller {
	
	function index()
	{
		$this->get_route("/","home");
		$this->get_route("/sample","sample");
		$this->load->model('homeRouting');
		$this->run($this->homeRouting);
    }
}

Create Model at system/application/model/homeRouting.php

<?php
class homeRoutingModel extends Ava_Model {
	
	function home() {
		//home /
		$this->load->model('home');
	}

	function sample() {
		//sample /sample
		$this->load->model('sample');
	}
}

Create view at system/application/view/home.php and system/application/view/sample.php

home.php

<?php echo "HOME"; ?>

sample.php

<?php echo "sample"; ?>

Testing in browser

http://localhost/Ava/
http://localhost/Ava/home/sample

Clone this wiki locally