Last active
February 21, 2023 20:49
-
-
Save carestad/b4b59cdb6c82cb3229f4908c3c8372e9 to your computer and use it in GitHub Desktop.
Laravel superglobals cheat sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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