Upgrading Laravel 5.5 to 5.6 error

前端 未结 12 1873
梦如初夏
梦如初夏 2020-12-08 09:38

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         


        
相关标签:
12条回答
  • 2020-12-08 10:12

    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

    0 讨论(0)
  • 2020-12-08 10:12

    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.

    0 讨论(0)
  • 2020-12-08 10:17

    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.

    0 讨论(0)
  • 2020-12-08 10:18

    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

    0 讨论(0)
  • 2020-12-08 10:21

    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,  
    ];
    
    0 讨论(0)
  • 2020-12-08 10:25

    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
    
    0 讨论(0)
提交回复
热议问题