在 ErrorHandler.php 中找不到类“Psr\Log\LogLevel”
Posted
技术标签:
【中文标题】在 ErrorHandler.php 中找不到类“Psr\\Log\\LogLevel”【英文标题】:Class 'Psr\Log\LogLevel' not found in ErrorHandler.php在 ErrorHandler.php 中找不到类“Psr\Log\LogLevel” 【发布时间】:2016-03-21 10:12:03 【问题描述】:使用composer update
或composer install
得到这个错误:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
php Fatal error: Class 'Psr\Log\LogLevel' not found in /var/www/html/Project/MRA/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php on line 121
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
PHP Fatal error: Class 'Psr\Log\LogLevel' not found in /var/www/html/Project/MRA/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php on line
121
.
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...
我使用的是 symfony 2.7.7,这是我的 composer.json:
"php": ">=5.3.9", "symfony/symfony": "2.7.*", “教义/orm”:“^2.4.8”, "doctrine/doctrine-bundle": "~1.4", "symfony/assetic-bundle": "~2.3", "symfony/swiftmailer-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", “sensio/distribution-bundle”:“~4.0”, “sensio/framework-extra-bundle”:“^3.0.2”, “incenteev/composer-parameter-handler”:“~2.0”, “friendsofsymfony/user-bundle”:“~1.3”, “mopa/bootstrap-bundle”:“dev-master”, "twbs/bootstrap": "^3.3", “knplabs/knp-paginator-bundle”:“dev-master”, “knplabs/knp-menu-bundle”:“2.0.*@dev”, "knplabs/knp-menu": "2.0.*@dev", “craue/formflow-bundle”:“~2.0”, “friendsofsymfony/rest-bundle”:“^1.7”, "sonata-project/admin-bundle": "2.3.*", "sonata-project/doctrine-orm-admin-bundle": "2.3.*", "sonata-project/user-bundle": "dev-master", "sonata-project/datagrid-bundle": "dev-master", "siphoc/pdf-bundle": "1.2.*", “knplabs/knp-snappy-bundle”:“^1.3”, “奏鸣曲项目/easy-extends-bundle”:“^2.1”【问题讨论】:
rm -rf app/cache/*
激进模式...
您的作曲家文件中应该有这样的一行:“Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache”。您可以暂时禁用任何 postInstall 脚本以让 composer 完成,然后手动调试自动加载器不工作的原因。
【参考方案1】:
好的,PSR Logger 不在 composer.json 中,所以我添加了
"psr/log": "dev-master"
转换为 composer.json
并修复了错误。
PS:不知道为什么突然没安装就不行了!
【讨论】:
以上是关于在 ErrorHandler.php 中找不到类“Psr\Log\LogLevel”的主要内容,如果未能解决你的问题,请参考以下文章
在 laravel 5.4 中找不到类“Illuminate\Foundation\Application”