Skip to content

Instantly share code, notes, and snippets.

@lukemorton
Created January 23, 2011 18:00
Show Gist options
  • Save lukemorton/792279 to your computer and use it in GitHub Desktop.
Save lukemorton/792279 to your computer and use it in GitHub Desktop.
Your first Kohana 3.1 controller
<?php
// Excerpt from bootstrap.php
Kohana::init(
array(
'base_url' => '/',
'index_file' => '', // Important
)
);
<?php
Route::set('hello', '')
->defaults(
array(
'controller' => 'hello',
)
);
<?php
Route::set('hello', '(<name>)')
->defaults(
array(
'controller' => 'hello',
)
);
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Hello extends Controller {
public function action_index()
{
$this->response->body('hello world');
}
}
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Hello extends Controller {
public function action_index()
{
$name = $this->request->param('name', 'world');
$this->response->body("hello {$name}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment