本文整理汇总了PHP中Illuminate\Support\Facades\Input::server方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::server方法的具体用法?PHP Input::server怎么用?PHP Input::server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Input
的用法示例。
在下文中一共展示了Input::server方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: respondWithArray
protected function respondWithArray(array $array, array $headers = [])
{
$mimeTypeRaw = Input::server('HTTP_ACCEPT', '*/*');
// If its empty or has */* then default to JSON
if ($mimeTypeRaw === '*/*') {
$mimeType = 'application/json';
} else {
// You'll probably want to do something intelligent with charset if provided
// This chapter just assumes UTF8 everything everywhere
$mimeParts = (array) explode(',', $mimeTypeRaw);
$mimeType = strtolower($mimeParts[0]);
}
switch ($mimeType) {
case 'application/json':
$contentType = 'application/json';
$content = json_encode($array);
break;
case 'application/x-yaml':
$contentType = 'application/x-yaml';
$dumper = new YamlDumper();
$content = $dumper->dump($array, 2);
break;
default:
$contentType = 'application/json';
$content = json_encode(['error' => ['code' => static::CODE_INVALID_MIME_TYPE, 'http_code' => 415, 'message' => sprintf('Content of type %s is not supported.', $mimeType)]]);
}
$response = Response::make($content, $this->statusCode, $headers);
$response->header('Content-Type', $contentType);
return $response;
}
示例2: map
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
#if (!$this->app->routesAreCached()) {
// Handle legacy routes
$router->get('blog/wp-content/uploads/{img_ref_path}', function ($img_ref_path) {
return file_get_contents(img_path($img_ref_path));
});
$router->group(['namespace' => $this->namespace], function ($router) {
if (in_array(Input::server('HTTP_HOST'), ['www.joejiko.com', 'local.joejiko.com'])) {
require_once __DIR__ . '/../Http/routes.php';
}
});
#}
}