Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error while updating laravel from 5.5 to 5.7 (Undefined class constant 'HEADER_CLIENT_IP')

Tags:

php

laravel

xampp

i am getting this error.

Undefined class constant 'HEADER_CLIENT_IP' Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

I changed

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;
  }

Here is my .composerjson file

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.0.0",
        "fideloper/proxy": "~3.3",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "~1.0",
        "tymon/jwt-auth": "^0.5.12"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "~1.0",
        "phpunit/phpunit": "~6.0",
        "symfony/thanks": "^1.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    } }

I am still handling the same error. Can you guys figure it out where the problem is ?

like image 428
alphal Avatar asked Dec 05 '22 10:12

alphal


1 Answers

At composer.json Change fideloper/proxy

From

"fideloper/proxy": "~3.3",

To

"fideloper/proxy": "^4.0",

After that run

composer update
like image 74
iHabboush Avatar answered Dec 28 '22 07:12

iHabboush