Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Laravel superglobals cheat sheet
<?php
$_SERVER['HTTP_HOST'] = Request::getHttpHost();
$_SERVER['HTTP_HOST'] = request()->getHttpHost();
// Alternative could be to use URL::previous(), but this will always return current URL if no referer is present.
// @see https://github.com/laravel/framework/blob/5.7/src/Illuminate/Routing/UrlGenerator.php#L154
$_SERVER['HTTP_REFERER'] = Request::header('referer', 'default');
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = Request::getPreferredLanguage();
$_SERVER['HTTP_USER_AGENT'] = Request::userAgent();
$_SERVER['REQUEST_URI'] = Request::getRequestUri();
$_SERVER['REQUEST_URI'] = request()->getRequestUri();
$_SERVER['SERVER_NAME'] = Request::server('SERVER_NAME');
$_GET['foo'] = Request::query('foo');
$_POST['foo'] = Request::input('foo');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment