简体   繁体   English

Laravel PHP Artisan类日志未找到

[英]Laravel php artisan class log does not find

centos7.0 centos7.0

laravel 5.1.11 laravel 5.1.11

php7.0 php7.0

"php artisan" message: “ php artisan”消息:

    Fatal error: Uncaught ReflectionException: Class log does not exist in /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php:741
Stack trace:
#0 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(741): ReflectionClass->__construct('log')
#1 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('log', Array)
#2 /home/website/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('log', Array)
#3 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(842): Illuminate\Foundation\Application->make('log')
#4 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(774): Illuminate\Container\Container->getDependencies(Array, Array)
#6 /home/website/vendor/ in /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 741

The error was thrown because one of the values in the .env file may have spaces. 因为.env文件中的值之一可能包含空格,所以引发了错误。

Just enclosed any values with space in double quotes. 只需将任何值都用双引号引起来。

For example let's assume that this is part of your .env file 例如,假设这是您的.env文件的一部分

APP_ENV=local
APP_DEBUG=true
APP_KEY=This Will Cause An Error

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

....

APP_KEY=This Will Cause An Error will cause this issue because it needs to be in quotes like: APP_KEY=This Will Cause An Error将导致此问题,因为它需要用引号引起来,例如:

APP_KEY="This Will Work"

Also any space after the values may cause the same issue too 同样,值后面的任何空格也可能导致相同的问题

In my case the reason for this error was a missing php extension. 就我而言,此错误的原因是缺少php扩展名。 Since this missing extension raises an error, the logger tries to log it. 由于缺少此扩展名会引发错误,因此记录器尝试对其进行记录。 This exception appears as a result of no 'log' class resolved from the container. 由于没有从容器解析“ log”类而出现此异常。 I think this is a Laravel bug. 我认为这是Laravel错误。

Check your Apache user and file system user first. 首先检查您的Apache用户和文件系统用户。 Then run the following commands to set file system permissions: 然后运行以下命令来设置文件系统权限:

sudo chmod 755 storage -R
sudo chmod 755 vendor -R
sudo chmod 755 bootstrap -R

After you finished changing the file permissions, clean your chache with the following commands: 在完成文件权限的更改之后,请使用以下命令清理您的缓存:

php artisan config:cache
php artisan cache:clear
php artisan config:clear

This works for me. 这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM