问题
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 ?
回答1:
At composer.json Change fideloper/proxy
From
"fideloper/proxy": "~3.3",
To
"fideloper/proxy": "^4.0",
After that run
composer update
回答2:
1) change your composer.json to following
"php": ">=7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.7.*",
"laravel/tinker": "~1.0",
2) change your App\Http\Middleware\TrustProxies.php to following
<?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|string
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}
3) remove the file from the config directory having name trustedproxy.php if exist
4) run the following command into the console from your application directory
composer update
5) this step is not necessary but it will clear all cache and autoload files
php artisan clear-compiled
composer dump-autoload
php artisan cache:clear
php artisan config:clear
php artisan view:clear
回答3:
Did you try to update the composer
composer update
and dump the autoload ?
composer dump-autoload
来源:https://stackoverflow.com/questions/52984601/getting-error-while-updating-laravel-from-5-5-to-5-7-undefined-class-constant