本文整理汇总了PHP中Slim\App::group方法的典型用法代码示例。如果您正苦于以下问题:PHP App::group方法的具体用法?PHP App::group怎么用?PHP App::group使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\App
的用法示例。
在下文中一共展示了App::group方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setSlimRules
private function setSlimRules($rules)
{
foreach ($rules as $controllers) {
if (isset($controllers['groups'])) {
$this->slim->group($controllers['pattern'], function () use($controllers) {
foreach ($controllers['groups'] as $controller) {
$this->map($controller['methods'], $controller['pattern'], $controller['action'])->setName($controller['name']);
}
});
} else {
$this->slim->map($controllers['methods'], $controllers['pattern'], $controllers['action'])->setName($controllers['name']);
}
}
}
示例2: __construct
public function __construct(App $app)
{
$app->group('/periodos', function () {
$this->get('/actual', RetriveActualAction::class);
$this->get('/{anio}', RetrivePeriodosDelAnio::class);
});
}
示例3: init
public function init(\Slim\App $app)
{
$app->group('/categories', function () {
$this->get('', '\\Controllers\\Categories:index');
$this->map(['GET', 'POST'], '/created', '\\Controllers\\Categories:created');
$this->map(['GET', 'POST'], '/edit/{id}', '\\Controllers\\Categories:edit');
$this->map(['GET', 'POST'], '/delete/{id}', '\\Controllers\\Categories:delete');
});
}
示例4: registerRoute
public function registerRoute(Slim $app)
{
$data = $this->getInfo();
$app->group($data['path'], function () use($data) {
$this->get('', $data['handle'] . ':index')->setName('list.' . $data['name']);
$this->get('/add', $data['handle'] . ':add')->setName('add.' . $data['name']);
$this->get('/edit/{id:\\d+}', $data['handle'] . ':edit')->setName('edit.' . $data['name']);
$this->map(['PUT', 'POST'], '/add', $data['handle'] . ':doAdd')->setName('store.' . $data['name']);
$this->map(['PUT', 'POST'], '/edit', $data['handle'] . ':doEdit')->setName('save.' . $data['name']);
$this->map(['DELETE', 'POST'], '/delete/{id:\\d+}', $data['handle'] . ':doDelete')->setName('delete.' . $data['name']);
});
}
示例5: register
/**
* Register DebugBar service.
*
* @param App $app
*
* @return void
*/
public function register(App $app)
{
$container = $app->getContainer();
$container['debugbar'] = function ($container) {
return new SlimDebugBar($container, $this->settings);
};
if (!$this->settings['enabled']) {
return;
}
$app->group('/_debugbar', function () {
$this->get('/open', 'Kitchenu\\Debugbar\\Controllers\\OpenHandlerController:handle')->setName('debugbar-openhandler');
$this->get('/assets/stylesheets', 'Kitchenu\\Debugbar\\Controllers\\AssetController:css')->setName('debugbar-assets-css');
$this->get('/assets/javascript', 'Kitchenu\\Debugbar\\Controllers\\AssetController:js')->setName('debugbar-assets-js');
});
$app->add(new Debugbar($container['debugbar'], $container['errorHandler']));
}
示例6: Container
$configuration = ['settings' => ['displayErrorDetails' => $debug]];
$c = new Container($configuration);
// Make a Slim App
$app = new App($c);
// Home
$app->get('/', 'App\\Controllers\\HomeController:index');
$app->get('/code', 'App\\Controllers\\HomeController:code');
// User Center
$app->group('/user', function () {
$this->get('', 'App\\Controllers\\UserController:index');
$this->get('/', 'App\\Controllers\\UserController:index');
$this->post('/checkin', 'App\\Controllers\\UserController:doCheckin');
$this->get('/node', 'App\\Controllers\\UserController:node');
$this->get('/node/{id}', 'App\\Controllers\\UserController:nodeInfo');
$this->get('/profile', 'App\\Controllers\\UserController:profile');
$this->get('/invite', 'App\\Controllers\\UserController:invite');
$this->post('/invite', 'App\\Controllers\\UserController:doInvite');
$this->get('/edit', 'App\\Controllers\\UserController:edit');
$this->post('/password', 'App\\Controllers\\UserController:updatePassword');
$this->post('/sspwd', 'App\\Controllers\\UserController:updateSsPwd');
$this->post('/method', 'App\\Controllers\\UserController:updateMethod');
$this->get('/sys', 'App\\Controllers\\UserController:sys');
$this->get('/logout', 'App\\Controllers\\UserController:logout');
})->add(new Auth());
// Auth
$app->group('/auth', function () {
$this->get('/login', 'App\\Controllers\\AuthController:login');
$this->post('/login', 'App\\Controllers\\AuthController:loginHandle');
$this->get('/register', 'App\\Controllers\\AuthController:register');
$this->post('/register', 'App\\Controllers\\AuthController:registerHandle');
$this->get('/logout', 'App\\Controllers\\AuthController:logout');
})->add(new Guest());
示例7: App
/***
* The slim documents: http://www.slimframework.com/docs/objects/router.html
*/
$app = new App();
// Home
$app->get('/', 'App\\Controllers\\HomeController:home');
$app->get('/code', 'App\\Controllers\\HomeController:code');
// User Center
$app->group('/user', function () {
$this->get('', 'App\\Controllers\\UserController:home');
$this->get('/', 'App\\Controllers\\UserController:home');
$this->post('/checkin', 'App\\Controllers\\UserController:doCheckin');
$this->get('/node', 'App\\Controllers\\UserController:node');
$this->get('/node/{id}', 'App\\Controllers\\UserController:nodeInfo');
$this->get('/profile', 'App\\Controllers\\UserController:profile');
$this->get('/invite', 'App\\Controllers\\UserController:invite');
$this->post('/invite', 'App\\Controllers\\UserController:doInvite');
$this->get('/edit', 'App\\Controllers\\UserController:edit');
$this->post('/password', 'App\\Controllers\\UserController:updatePassword');
$this->post('/sspwd', 'App\\Controllers\\UserController:updateSsPwd');
$this->get('/sys', 'App\\Controllers\\UserController:sys');
$this->get('/logout', 'App\\Controllers\\UserController:logout');
})->add(new Auth());
// Auth
$app->group('/auth', function () {
$this->get('/login', 'App\\Controllers\\AuthController:login');
$this->post('/login', 'App\\Controllers\\AuthController:loginHandle');
$this->get('/register', 'App\\Controllers\\AuthController:register');
$this->post('/register', 'App\\Controllers\\AuthController:registerHandle');
$this->get('/logout', 'App\\Controllers\\AuthController:logout');
})->add(new Guest());
示例8: testGroupDefaultSlash
public function testGroupDefaultSlash()
{
$app = new App();
$app->group('/foo', function () use($app) {
$app->get('/', function ($req, $res) {
// Do something
});
});
/** @var \Slim\Router $router */
$router = $app->router;
$router->finalize();
$this->assertAttributeEquals('/foo', 'pattern', $router->lookupRoute('route0'));
$app = new App();
$app->group('/foo', function () use($app) {
$app->get('/bar', function ($req, $res) {
// Do something
});
});
/** @var \Slim\Router $router */
$router = $app->router;
$router->finalize();
$this->assertAttributeEquals('/foo/bar', 'pattern', $router->lookupRoute('route0'));
$app = new App();
$app->group('/foo', function () use($app) {
$app->group('/baz', function () use($app) {
$app->get('/', function ($req, $res) {
// Do something
});
});
});
/** @var \Slim\Router $router */
$router = $app->router;
$router->finalize();
$this->assertAttributeEquals('/foo/baz', 'pattern', $router->lookupRoute('route0'));
$app = new App();
$app->group('/foo', function () use($app) {
$app->get('/bar/', function ($req, $res) {
// Do something
});
});
/** @var \Slim\Router $router */
$router = $app->router;
$router->finalize();
$this->assertAttributeEquals('/foo/bar/', 'pattern', $router->lookupRoute('route0'));
}
示例9: setGroups
/**
* Sets routing groups to be used on dynamic routing
*
* @param \Slim\App $app Reference to slim app
* @param string $group Main group name
* @param string $subGroup Secondary group name
*
* @return void
* @access protected
*/
private function setGroups(\Slim\App $app, $group, $subGroup = null)
{
$ns = $this->namespace;
$app->group('/' . $group, function () use($subGroup, $ns) {
// Version group
if ($subGroup !== null) {
$this->group('/' . $subGroup, function () use($ns) {
\mbarquin\SlimDR\Factory::setMap($this, $ns);
});
// End api group.
} else {
\mbarquin\SlimDR\Factory::setMap($this, $ns);
}
});
}
示例10: testEmptyGroupWithEmptyNestedGroupAndSegmentRouteWithoutLeadingSlash
public function testEmptyGroupWithEmptyNestedGroupAndSegmentRouteWithoutLeadingSlash()
{
$app = new App();
$app->group('', function () use($app) {
$app->group('', function () use($app) {
$app->get('bar', function ($req, $res) {
// Do something
});
});
});
/** @var \Slim\Router $router */
$router = $app->router;
$router->finalize();
$this->assertAttributeEquals('/bar', 'pattern', $router->lookupRoute('route0'));
}
示例11: init
public function init(\Slim\App $app)
{
$app->group('/api', function () {
$this->get('/get-catalog', '\\Controllers\\Api:getCatalog');
});
}
示例12: function
$app->get('/', 'App\\Controllers\\HomeController:index');
$app->get('/code', 'App\\Controllers\\HomeController:code');
$app->get('/tos', 'App\\Controllers\\HomeController:tos');
$app->get('/debug', 'App\\Controllers\\HomeController:debug');
$app->post('/debug', 'App\\Controllers\\HomeController:postDebug');
// User Center
$app->group('/user', function () {
$this->get('', 'App\\Controllers\\UserController:index');
$this->get('/', 'App\\Controllers\\UserController:index');
$this->post('/checkin', 'App\\Controllers\\UserController:doCheckin');
$this->get('/node', 'App\\Controllers\\UserController:node');
$this->get('/node/{id}', 'App\\Controllers\\UserController:nodeInfo');
$this->get('/profile', 'App\\Controllers\\UserController:profile');
$this->get('/invite', 'App\\Controllers\\UserController:invite');
$this->post('/invite', 'App\\Controllers\\UserController:doInvite');
$this->get('/edit', 'App\\Controllers\\UserController:edit');
$this->post('/password', 'App\\Controllers\\UserController:updatePassword');
$this->post('/sspwd', 'App\\Controllers\\UserController:updateSsPwd');
$this->post('/method', 'App\\Controllers\\UserController:updateMethod');
$this->get('/sys', 'App\\Controllers\\UserController:sys');
$this->get('/trafficlog', 'App\\Controllers\\UserController:trafficLog');
$this->get('/kill', 'App\\Controllers\\UserController:kill');
$this->post('/kill', 'App\\Controllers\\UserController:handleKill');
$this->get('/logout', 'App\\Controllers\\UserController:logout');
})->add(new Auth());
// Auth
$app->group('/auth', function () {
$this->get('/login', 'App\\Controllers\\AuthController:login');
$this->post('/login', 'App\\Controllers\\AuthController:loginHandle');
$this->get('/register', 'App\\Controllers\\AuthController:register');
$this->post('/register', 'App\\Controllers\\AuthController:registerHandle');
示例13: testGroup
public function testGroup()
{
$app = new App();
$app->group('/foo', function () use($app) {
$route = $app->get('/bar', function ($req, $res) {
// Do something
});
});
/** @var \Slim\Router $router */
$router = $app->router;
$router->finalize();
$this->assertAttributeEquals('/foo/bar', 'pattern', $router->getRoutes()[0]);
}
示例14: App
use Slim\App;
use App\Controllers;
use App\Middleware\Auth;
use App\Middleware\Guest;
/***
* The slim documents: http://www.slimframework.com/docs/objects/router.html
*/
$app = new App();
// Home
$app->get('/', 'App\\Controllers\\HomeController:home');
$app->get('/code', 'App\\Controllers\\HomeController:code');
// User Center
$app->group('/user', function () {
$this->get('/', 'App\\Controllers\\UserController:home');
$this->get('/node', 'App\\Controllers\\UserController:node');
$this->get('/profile', 'App\\Controllers\\UserController:profile');
$this->get('/invite', 'App\\Controllers\\UserController:invite');
$this->get('/sys', 'App\\Controllers\\UserController:sys');
$this->get('/logout', 'App\\Controllers\\UserController:logout');
})->add(new Auth());
// Auth
$app->group('/auth', function () {
$this->get('/login', 'App\\Controllers\\AuthController:login');
$this->post('/login', 'App\\Controllers\\AuthController:loginHandle');
$this->get('/register', 'App\\Controllers\\AuthController:register');
$this->post('/register', 'App\\Controllers\\AuthController:registerHandle');
$this->get('/logout', 'App\\Controllers\\AuthController:logout');
})->add(new Guest());
// Run Slim Routes for App
$app->run();
示例15: testAddMiddlewareOnRouteAndOnTwoRouteGroup
public function testAddMiddlewareOnRouteAndOnTwoRouteGroup()
{
$app = new App();
$app->group('/foo', function () use($app) {
$app->group('/baz', function () use($app) {
$app->get('/', function ($req, $res) {
return $res->write('Center');
})->add(function ($req, $res, $next) {
$res->write('In3');
$res = $next($req, $res);
$res->write('Out3');
return $res;
});
})->add(function ($req, $res, $next) {
$res->write('In2');
$res = $next($req, $res);
$res->write('Out2');
return $res;
});
})->add(function ($req, $res, $next) {
$res->write('In1');
$res = $next($req, $res);
$res->write('Out1');
return $res;
});
// Prepare request and response objects
$env = Environment::mock(['SCRIPT_NAME' => '/index.php', 'REQUEST_URI' => '/foo/baz/', 'REQUEST_METHOD' => 'GET']);
$uri = Uri::createFromEnvironment($env);
$headers = Headers::createFromEnvironment($env);
$cookies = [];
$serverParams = $env->all();
$body = new RequestBody();
$req = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
$res = new Response();
// Invoke app
$app($req, $res);
$this->assertEquals('In1In2In3CenterOut3Out2Out1', (string) $res->getBody());
}