Upgrading Laravel 5.5 to 5.6 error
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:
<?phpnamespace 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 yourproviders
array inconfig/app.php
.Update your composer.json file to use "fideloper/proxy": "~4.0". Run
composer update fideloper/proxy
to update the package.
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