I am trying to upgrade my Laravel 5.5
to 5.6.
I have followed the instructions from the laravel website, yet I got this error:
Your
I did this and it works perfectly.
1. composer.json:
From:
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0"
},
To:
"require": {
"php": ">=7.1.3",
"fideloper/proxy": "~4.0",
"laravel/framework": "5.6.*",
"laravel/tinker": "~1.0"
},
2. Replace app\Http\Middleware\TrustedProxies.php file with contents below:
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var string
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}
3. composer update
Laravel's Request object extends Symfony's Request object. Laravel 5.5 depends on Symfony 3, which has that constant. Laravel 5.6 depends on Symfony 4, which does not have that constant.
Based on your trusted proxies configuration, it looks like you're using the trusted proxies package "outside" of Laravel. Laravel brought the trusted proxies package inside the framework in 5.5, and created a dedicated \App\Http\Middleware\TrustProxies
middleware for you to use.
I would suggest moving to use the middleware and configuring it as described in the Laravel documentation. This will help prevent this type of compatibility issue in the future.
To make the switch:
In app/Http/Kernel.php
, if \Fideloper\Proxy\TrustProxies::class
is in your $middleware
array, remove it. If \App\Http\Middleware\TrustProxies::class
is not in your $middleware
array, add it.
Open your app/Http/Middleware/TrustProxies.php
file and update it with your proxies.
Delete your config/trustedproxy.php
file.
Remove Fideloper\Proxy\TrustedProxyServiceProvider::class
from your providers
array in config/app.php
.
Update your composer.json file to use "fideloper/proxy": "~4.0". Run composer update fideloper/proxy
to update the package.
None of the suggestions here worked for me for some reason. I am using quickadmin panel and various dependencies which might have something to do with it.
What finally worked was removing laravel/dusk, then updating to "fideloper/proxy": "~4.0",
on it's own. Then updating laravel/framework to 5.6, then reinstalling dusk.
I did not need:
"minimum-stability":"dev",
"prefer-stable": true,
Maybe that was fixed with recent updates.
I have updated from 5.5 to 5.6
composer.json
"minimum-stability":"dev",
"prefer-stable": true,
This will install latest Laravel packages, then there will be issue with TrustedProxies
.
Install the latest proxy version for Laravel 5.6.
Please use tag 4.0+ for Laravel 5.6:
composer require fideloper/proxy:~4.0
More details
Replace app\Http\Middleware\TrustedProxies.php by:
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
protected $proxies;
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}
Replace config\trustedproxy.php by:
<?php
return [
'proxies' => null,
'headers' => Illuminate\Http\Request::HEADER_X_FORWARDED_ALL,
];
Just need to Change fideloper/proxy in composer.json file:-
Your composer.json file now:-
"fideloper/proxy": "~3.3",
Change it to ^4.0 somthing like this:-
"fideloper/proxy": "^4.0",
After that you need to run update composer that's it.
composer update