当前位置: 首页>>代码示例>>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;未经允许,请勿转载。