laravel 未找到“Monolog\Logger”类 - 全新安装问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22990481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:20:37  来源:igfitidea点击:

Class 'Monolog\Logger' not found - Fresh install issue

laravel

提问by Jan Moty?ák

I just installed fresh installation of Laravel framework and I got error which I can't resolve.

我刚刚安装了全新安装的 Laravel 框架,但出现了无法解决的错误。

I just follow the Laravel official instruction on http://laravel.com/docs/quickand the issue rise when I try to Routing

我只是按照http://laravel.com/docs/quick上的 Laravel 官方说明进行操作,当我尝试路由时问题就出现了

I have no idea how to fix it and I can't find solution for this issue.

我不知道如何解决它,我找不到这个问题的解决方案。

I installed Laravel withoutthe Composer

我在没有Composer 的情况下安装了 Laravel

System info

系统信息

  • PHP Version 5.4.4-14+deb7u8
  • Linux morpheus 3.10.36+ #664 PREEMPT Mon Apr 7 14:01:14 BST 2014 armv6l
  • Apache/2.2.22 (Debian)
  • PHP 版本 5.4.4-14+deb7u8
  • Linux morpheus 3.10.36+ #664 PREEMPT Mon Apr 7 14:01:14 BST 2014 armv6l
  • Apache/2.2.22 (Debian)

Thank you in advance! Jan

先感谢您!简

enter image description here

在此处输入图片说明

回答by Paul Bele

First Solution : In your composer.json file, please change "minimum-stability" from "dev" to "stable" I had the same issue and did the trick Then run composer dump-autoload

第一个解决方案:在您的 composer.json 文件中,请将“最低稳定性”从“开发”更改为“稳定”我遇到了同样的问题并完成了技巧然后运行 composer dump-autoload

This is a problem that arrived from Laravel 4.1.

这是来自 Laravel 4.1 的问题。

Second solution : If that didn't solved the issue, you can try :

第二种解决方案:如果这没有解决问题,您可以尝试:

composer self-update

and then

进而

composer update

Third solution : Try running :

第三种解决方案:尝试运行:

composer update --no-scripts

Or use namespaces:

或者使用命名空间:

$log = new \Monolog\Logger('email');
$log->pushHandler(new \Monolog\Handler\StreamHandler('path/to/file.log', \Monolog\Logger::WARNING));
$log->addWarning('Some message.');