當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Slim::options方法代碼示例

本文整理匯總了PHP中Slim\Slim::options方法的典型用法代碼示例。如果您正苦於以下問題:PHP Slim::options方法的具體用法?PHP Slim::options怎麽用?PHP Slim::options使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Slim\Slim的用法示例。


在下文中一共展示了Slim::options方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: optionsStation

 /**
  * @SWG\Api(
  *   path="/gas-stations/{gasStationId}",
  *   @SWG\Operation(
  *     method="OPTIONS",
  *     summary="Get the valid options of a gas station",
  *     nickname="optionsGasStation",
  *     @SWG\Parameter(
  *       name="gasStationId",
  *       description="ID of gas station",
  *       paramType="path",
  *       required=true,
  *       type="integer"
  *     ),
  *     @SWG\ResponseMessage(
  *       code=404,
  *       message="Gas station not found"
  *     )
  *   )
  * )
  */
 protected function optionsStation()
 {
     $this->app->options('/gas-stations/:id', function ($id) {
         $this->app->stationController->options();
     });
 }
開發者ID:comphppuebla,項目名稱:echale-gas-api,代碼行數:27,代碼來源:StationRoutes.php

示例2: function

$app->put('/:resource(/(:action)(/))', function ($resource, $subResource = null) use($app) {
    $resource = Resource::load($app->version, $resource, $subResource);
    if ($resource === null) {
        Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');
    } else {
        $resource->put();
    }
});
// Delete
$app->delete('/:resource(/(:action)(/))', function ($resource, $subResource = null) use($app) {
    $resource = Resource::load($app->version, $resource, $subResource);
    if ($resource === null) {
        Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');
    } else {
        $resource->delete();
    }
});
// Options
$app->options('/:resource(/(:action)(/))', function ($resource, $subResource = null) use($app) {
    $resource = Resource::load($app->version, $resource, $subResource);
    if ($resource === null) {
        Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');
    } else {
        $resource->options();
    }
});
// Not found
$app->notFound(function () {
    Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');
});
$app->run();
開發者ID:rohanabraham,項目名稱:lxHive,代碼行數:31,代碼來源:index.php

示例3: function

$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;
    }
    if (empty($contact['last_name'])) {
        $contact['last_name'] = $app->faker->lastName;
    }
    $lastModifiedTime = time();
    $app->lastModified($lastModifiedTime);
    $app->status(200);
    echo $app->render($app->template, ['contact' => $contact]);
});
$app->delete('/contacts/:id', function ($id) use($app) {
    //Delete contact here
    $app->status(204);
});
$app->options('/contacts/:id', function ($id) use($app) {
    $validOptions = ['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS'];
    $app->response()->header('Allow', implode(',', $validOptions));
});
$app->run();
開發者ID:comphppuebla,項目名稱:guzzlesfd,代碼行數:31,代碼來源:index.php

示例4: Slim

<?php

require 'vendor/autoload.php';
use Slim\Slim;
$app = new Slim();
// Replace /comphppuebla/guzzle for the path to your http-verbs.php file to try this route.
// curl -X GET http://localhost/comphppuebla/guzzle/contacts/1
$app->get('/contacts/:id', function ($id) {
    echo "Request via GET with ID = {$id}";
});
// Replace /comphppuebla/guzzle for the path to your http-verbs.php file to try this route.
// curl -X POST http://localhost/comphppuebla/guzzle/contacts
$app->post('/contacts', function () {
    echo "Request via POST";
});
// Replace /comphppuebla/guzzle for the path to your http-verbs.php file to try this route.
// curl -X PUT http://localhost/comphppuebla/guzzle/contacts/2
$app->put('/contacts/:id', function ($id) {
    echo "Request via PUT with ID = {$id}";
});
// Replace /comphppuebla/guzzle for the path to your http-verbs.php file to try this route.
// curl -X DELETE http://localhost/comphppuebla/guzzle/contacts/3
$app->delete('/contacts/:id', function ($id) {
    echo "Request via DELETE with ID = {$id}";
});
// Replace /comphppuebla/guzzle for the path to your http-verbs.php file to try this route.
// curl -X OPTIONS http://localhost/comphppuebla/guzzle/contacts/4
$app->options('/contacts/:id', function ($id) {
    echo "Request via OPTIONS with ID = {$id}";
});
$app->run();
開發者ID:comphppuebla,項目名稱:guzzlesfd,代碼行數:31,代碼來源:http-verbs.php


注:本文中的Slim\Slim::options方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。