本文整理汇总了PHP中Slim\Slim::status方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::status方法的具体用法?PHP Slim::status怎么用?PHP Slim::status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\Slim
的用法示例。
在下文中一共展示了Slim::status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
$contentNegotiation = function () use($app) {
$negotiator = new Negotiator();
$format = $negotiator->getBest($app->request()->headers('Accept'));
$type = $format->getValue();
$app->contentType($type);
$app->template = 'contacts/show.json.twig';
if ('application/xml' === $type) {
$app->template = 'contacts/show.xml.twig';
}
};
$app->post('/contacts', $contentNegotiation, function () use($app) {
$contactInformation = $app->request()->getBody();
parse_str($contactInformation, $contact);
$contact['contact_id'] = $app->faker->randomDigit;
//Simulate an insert
$app->status(201);
echo $app->render($app->template, ['contact' => $contact]);
});
$app->get('/contacts/:id', $contentNegotiation, function ($id) use($app) {
//This value should be specific to the current resource
$lastModifiedTime = gmdate('D, d M Y H:i:s ') . ' GMT';
$app->response()->header('Last-Modified', $lastModifiedTime);
$app->status(200);
echo $app->render($app->template, ['contact' => ['contact_id' => $id, 'name' => $app->faker->firstName, 'last_name' => $app->faker->lastName]]);
});
$app->put('/contacts/:id', $contentNegotiation, function ($id) use($app) {
$contactInformation = $app->request()->getBody();
parse_str($contactInformation, $contact);
$contact['contact_id'] = $id;
if (empty($contact['name'])) {
$contact['name'] = $app->faker->firstName;