dev-master
9999999-dev http://rawphp.orgRawRouter is a simple router used by RawPHP framework and other applications.
MIT
The Requires
The Development Requires
by Tom Kaczocha
routing
RawRouter is a simple router used by RawPHP framework and other applications.
RawRouter is available via Composer/Packagist., (*3)
Add "rawphp/raw-router": "0.*@dev"
to the require block in your composer.json and then run composer install
., (*4)
{ "require": { "rawphp/raw-router": "0.*@dev" } }
You can also simply run the following from the command line:, (*5)
composer require rawphp/raw-router "0.*@dev"
Alternatively, just copy the contents of the RawRouter folder into somewhere that's in your PHP include_path
setting. If you don't speak git or just want a tarball, click the 'zip' button at the top of the page in GitHub., (*6)
<?php use RawPHP\RawRouter\Router; // configuration $config = array( 'default_controller' => 'home', // the controller that will handle requests if the requested controller is not found 'default_action' => 'index', // the default action (method) to call if the requested action is not found 'namemspace' => 'RawPHP\\RawRouter\\Controllers\\', // the controllers namespace, leave empty if namespaces are not used ); // get new router instance $router = new Router( ); // initialise router $router->init( $config ); // example request // http://example.com/users/get/1 $route = 'users/get'; // the route must be in one of the following formats [ controller, controller/action, controller/action/param/param/... ] $params = array( 1 ); // array of values to be passed to the action method in the correct order // create controller $controller = $router->createController( $route, $params ); // run controller action $controller->run( );
This package is licensed under the MIT. Read LICENSE for information on the software availability and distribution., (*7)
Please submit bug reports, suggestions and pull requests to the GitHub issue tracker., (*8)
loadView()
method to Controller which can load html templatesinit()
methods to both Controllers to ensure that the controller gets initialised properly.setAction( IAction )
method on Controller.RawRouter is a simple router used by RawPHP framework and other applications.
MIT
routing