本文整理汇总了PHP中Silex\Application::PUT方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::PUT方法的具体用法?PHP Application::PUT怎么用?PHP Application::PUT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Silex\Application
的用法示例。
在下文中一共展示了Application::PUT方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
$app->DELETE('/v2/pet/{petId}', function (Application $app, Request $request, $pet_id) {
return new Response('How about implementing deletePet as a DELETE method ?');
});
$app->GET('/v2/pet/findByStatus', function (Application $app, Request $request) {
$status = $request->get('status');
return new Response('How about implementing findPetsByStatus as a GET method ?');
});
$app->GET('/v2/pet/findByTags', function (Application $app, Request $request) {
$tags = $request->get('tags');
return new Response('How about implementing findPetsByTags as a GET method ?');
});
$app->GET('/v2/pet/{petId}', function (Application $app, Request $request, $pet_id) {
return new Response('How about implementing getPetById as a GET method ?');
});
$app->PUT('/v2/pet', function (Application $app, Request $request) {
return new Response('How about implementing updatePet as a PUT method ?');
});
$app->POST('/v2/pet/{petId}', function (Application $app, Request $request, $pet_id) {
$name = $request->get('name');
$status = $request->get('status');
return new Response('How about implementing updatePetWithForm as a POST method ?');
});
$app->POST('/v2/pet/{petId}/uploadImage', function (Application $app, Request $request, $pet_id) {
$additional_metadata = $request->get('additional_metadata');
$file = $request->get('file');
return new Response('How about implementing uploadFile as a POST method ?');
});
$app->DELETE('/v2/store/order/{orderId}', function (Application $app, Request $request, $order_id) {
return new Response('How about implementing deleteOrder as a DELETE method ?');
});
$app->GET('/v2/store/inventory', function (Application $app, Request $request) {
示例2: function
// Request::setTrustedProxies(array($ip));
$app->GET('/', function (Application $app, Request $request) {
return new Response("<p>All good!</p>", 200);
});
// Category Routes
// All categories
$app->GET('/categories', function (Application $app, Request $request) {
$handler = new CategoryHandler();
$result = $handler->getAll();
return new Response($result, 200);
});
// Create category
$app->PUT('/categories', function (Application $app, Request $request) {
if (!authenticate('2', null)) {
return new Response('Unauthorized', 401);
}
$handler = new CategoryHandler();
$result = $handler->add($request->get('category_name'));
return new Response($result['message'], $result['status_code']);
});
// Update category
$app->POST('/categories/{category_id}', function (Application $app, Request $request, $category_id) {
if (!authenticate('2', null)) {
return new Response('Unauthorized', 401);
}
$object = array('category_id' => $category_id, 'new_category' => $request->get('category_name'));
$handler = new CategoryHandler();
$result = $handler->update($object);
return new Response($result['message'], $result['status_code']);
});
// Destroy category
$app->DELETE('/categories/{category_id}', function (Application $app, Request $request, $category_id) {
示例3: function
$app->POST('/apiKey/disable', function (Application $app, Request $request) {
$api_key_id = $request->get('api_key_id');
return new Response('How about implementing apiKey.disable as a POST method ?');
});
$app->POST('/apiKey/enable', function (Application $app, Request $request) {
$api_key_id = $request->get('api_key_id');
return new Response('How about implementing apiKey.enable as a POST method ?');
});
$app->GET('/user', function (Application $app, Request $request) {
return new Response('How about implementing user.getMe as a GET method ?');
});
$app->PUT('/user', function (Application $app, Request $request) {
$firstname = $request->get('firstname');
$lastname = $request->get('lastname');
$old_password = $request->get('old_password');
$new_password = $request->get('new_password');
$new_password_confirm = $request->get('new_password_confirm');
$country = $request->get('country');
$pgp_pub_key = $request->get('pgp_pub_key');
return new Response('How about implementing user.updateMe as a PUT method ?');
});
$app->POST('/user', function (Application $app, Request $request) {
$email = $request->get('email');
$password = $request->get('password');
$username = $request->get('username');
$firstname = $request->get('firstname');
$lastname = $request->get('lastname');
$accepts_tos = $request->get('accepts_tos');
$referrer_id = $request->get('referrer_id');
$country = $request->get('country');
return new Response('How about implementing user.newUser as a POST method ?');
});