ollie-troward / slim-controller
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: 2024-09-18 18:56:11 UTC
README
Slim 框架 V2 的控制器扩展。
关于
快速定义控制器路由和函数的简便方法。将它们放在类中,而不是使用匿名函数,使用轻量级可扩展的类来处理控制器。
用法
# 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();
许可
Slim Controller 是开源软件,根据 MIT 许可证 许可。