Created
January 23, 2011 18:00
-
-
Save lukemorton/792279 to your computer and use it in GitHub Desktop.
Your first Kohana 3.1 controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Excerpt from bootstrap.php | |
Kohana::init( | |
array( | |
'base_url' => '/', | |
'index_file' => '', // Important | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::set('hello', '') | |
->defaults( | |
array( | |
'controller' => 'hello', | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::set('hello', '(<name>)') | |
->defaults( | |
array( | |
'controller' => 'hello', | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
class Controller_Hello extends Controller { | |
public function action_index() | |
{ | |
$this->response->body('hello world'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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