Changes behaviour of koseven to support namespaces in controller class finding and loading
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
classes
LICENSE
README.md
composer.json

README.md

koseven-controller-namespace

Changes behaviour of koseven to support namespaces in controller class finding and loading.

Installation

composer require errotan/koseven-controller-namespace:dev-master

Setup

Enable the module in APPPATH/bootstrap.php by adding it to the modules initialization:

Kohana::modules([
	// ... all your other modules ...
	'koseven-controller-namespace' => DOCROOT.'vendor/errotan/koseven-controller-namespace',
]);

Add namespace:

Route::set('default', '(<controller>(/<action>(/<id>)))')
	->defaults([
		'namespace' => '\\First\\',
		'controller' => 'welcome',
		'action'     => 'index',
	]);

Also enable composer autoloader (vendor/autoload.php) in this file if not already done so.

Usage

Contrary to koseven style, controllers must be suffixed with 'Controller' and action methods need to be camelcased. Add controller file, for example src/First/WelcomeController.php

namespace First;

class WelcomeController extends \Controller
{
	public function actionIndex()
	{
		$this->response->body('hello, world!');
	}
}