Upgrading Laravel 5.5 to 5.6 error Upgrading Laravel 5.5 to 5.6 error php php

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:

  1. 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.

  2. Open your app/Http/Middleware/TrustProxies.php file and update it with your proxies.

  3. Delete your config/trustedproxy.php file.

  4. Remove Fideloper\Proxy\TrustedProxyServiceProvider::class from your providers array in config/app.php.

  5. 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

More details