ollie-troward / slim-controller
Controller extension for Slim
0.1
2015-11-07 21:18 UTC
Requires
- symfony/console: ^2.7
Requires (Dev)
- phpspec/nyan-formatters: 1.*
- phpspec/phpspec: ^2.3
- slim/slim: ^2.6
This package is not auto-updated.
Last update: 2025-04-02 21:41:13 UTC
README
A controller extension for the Slim Framework V2.
About
A quick way to define your controller routes and functions. Placing them in classes opposed to anonymous functions using a lightweight extensible class for your controllers.
Usage
# Instantiate your Slim application. $app = new \Slim\Slim(); # If you're using a namespace, include it here. $config = [ 'namespace' => 'My\\Controller\\Namespace' ]; # Include the SlimController class in your bootstrap file. $controller = new \Troward\SlimController\SlimController($app, $config); # Define your routes, you can use GET, POST, PUT and DELETE. $routes = [ 'GET' => [ # You need to define the URI as the key and the Controller@method as the value. '/' => 'ControllerClassName@controllerMethod', # Some examples are below 'hello' => 'HelloController@index', 'hello/:id' => 'HelloController@show' ] ]; # Register your routes in the SlimController. $controller->routes($routes); # Run your application. $app->run();
Licence
The Slim Controller is open-sourced software licensed under the MIT Licence.