本文整理匯總了PHP中Slim\App::patch方法的典型用法代碼示例。如果您正苦於以下問題:PHP App::patch方法的具體用法?PHP App::patch怎麽用?PHP App::patch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Slim\App
的用法示例。
在下文中一共展示了App::patch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testPatchRoute
public function testPatchRoute()
{
$path = '/foo';
$callable = function ($req, $res) {
// Do something
};
$app = new App();
$route = $app->patch($path, $callable);
$this->assertInstanceOf('\\Slim\\Route', $route);
$this->assertAttributeContains('PATCH', 'methods', $route);
}
示例2: function
$container['auth'] = function ($container) {
return new BB8\Emoji\Auth($container);
};
//Initialize the slim app
$app = new App($container);
//Add middleware at app level
$app->add('BB8\\Emoji\\Middleware:init');
//Index page
$app->get('/', 'BB8\\Emoji\\Controllers\\UserController:index');
//Create new user
$app->post('/signup', 'BB8\\Emoji\\Controllers\\UserController:create');
//Login Route
$app->post('/auth/login', 'BB8\\Emoji\\Controllers\\UserController:login');
//Logout Route
$app->get('/auth/logout', 'BB8\\Emoji\\Controllers\\UserController:logout')->add('BB8\\Emoji\\Middleware:authorize');
//List all emojis Route
$app->get('/emojis', 'BB8\\Emoji\\Controllers\\EmojiController:index');
//Gets an emoji
$app->get('/emojis/{id}', 'BB8\\Emoji\\Controllers\\EmojiController:show');
//Adds a new Emoji
$app->post('/emojis', 'BB8\\Emoji\\Controllers\\EmojiController:create')->add('BB8\\Emoji\\Middleware:authorize');
//Updates an Emoji
$app->put('/emojis/{id}', 'BB8\\Emoji\\Controllers\\EmojiController:update')->add('BB8\\Emoji\\Middleware:authorize');
//Updates an Emoji Keyword
$app->put('/emojis/{id}/{kId}', 'BB8\\Emoji\\Controllers\\EmojiController:updateKey')->add('BB8\\Emoji\\Middleware:authorize');
//Partially Updates an Emoji
$app->patch('/emojis/{id}', 'BB8\\Emoji\\Controllers\\EmojiController:update')->add('BB8\\Emoji\\Middleware:authorize');
//Deletes an Emoji
$app->delete('/emojis/{id}', 'BB8\\Emoji\\Controllers\\EmojiController:destroy')->add('BB8\\Emoji\\Middleware:authorize');
//Load and run the application
$app->run();