我已经想了好几天让Laravel工作。我无法确定的当前问题是未配置的数据库。
.env:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laracms
DB_USERNAME=homestead
DB_PASSWORD=secret
database.php:
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env( 'DB_HOST', '127.0.0.1' ),
'port' => env( 'DB_PORT', '3306' ),
'database' => env( 'DB_DATABASE', 'laracms' ),
'username' => env( 'DB_USERNAME', 'homestead' ),
'password' => env( 'DB_PASSWORD', 'secret' ),
'unix_socket' => env( 'DB_SOCKET', '' ),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
],
编辑:
Laravel.log
[2018-12-05 15:59:34] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Log/Log Manager.php:167)
[stacktrace]
#0 /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\\Log\\LogManager->resolve(NULL)
#1 /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(89): Illuminate\\Log\\LogManager->get(NULL)
#2 /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(490): Illuminate\\Log\\LogManager->driver()
#3 /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(114): Illuminate\\Log\\LogManager->error('syntax error, u...', Array)
#4 /home/vagrant/code/laracms/app/Exceptions/Handler.php(37): Illuminate\\Foundation\\Exceptions\\Handler->report(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#5 /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(353): App\\Exceptions\\Handler->report(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#6 /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(132): Illuminate\\Foundation\\Console\\Kernel->reportException(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#7 /home/vagrant/code/laracms/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#8 {main}
"}
[2018-12-05 15:59:34] laravel.ERROR: syntax error, unexpected ''connections'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' {"exception":" [object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): syntax error, unexpected ''connections'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' at /home/vagrant/code/laracms/config/database.php:45)
[stacktrace]
#0 /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(39): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\\Foundation\\Application), Object(Illuminate\\Config\\Repository))
#1 /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(204): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->bootstrap(Object(Illuminate\\Foundation\\Application))
#2 /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(297): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#3 /home/vagrant/code/laracms/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(120): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
#4 /home/vagrant/code/laracms/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#5 {main}
"}
答案 0 :(得分:0)
我终于要通过使用日志中的信息来重现您的确切错误:
[2018-12-18 10:32:25] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:167)
[stacktrace]
#0 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\\Log\\LogManager->resolve(NULL)
#1 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(89): Illuminate\\Log\\LogManager->get(NULL)
#2 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(490): Illuminate\\Log\\LogManager->driver()
#3 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(114): Illuminate\\Log\\LogManager->error('syntax error, u...', Array)
#4 /var/www/html/galaxus-explorer/app/Exceptions/Handler.php(37): Illuminate\\Foundation\\Exceptions\\Handler->report(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#5 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(314): App\\Exceptions\\Handler->report(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#6 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): Illuminate\\Foundation\\Http\\Kernel->reportException(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#7 /var/www/html/galaxus-explorer/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#8 {main}
"}
[2018-12-18 10:32:25] laravel.ERROR: syntax error, unexpected ''connections'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): syntax error, unexpected ''connections'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' at /var/www/html/galaxus-explorer/config/database.php:34)
[stacktrace]
#0 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(39): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\\Foundation\\Application), Object(Illuminate\\Config\\Repository))
#1 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(204): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->bootstrap(Object(Illuminate\\Foundation\\Application))
#2 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#3 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(146): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
#4 /var/www/html/galaxus-explorer/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#5 /var/www/html/galaxus-explorer/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#6 {main}
"}
在我看来,这是一个语法错误,因此我无法说出它为什么发生。看看我是怎么产生错误的,connections
键上的引号:
'''connections''' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
请仔细检查您的config/database.php
文件。您上传的文件和本地文件之间可能存在差异。 connections
键有问题或在此之前某处用引号引起了错误。最好您发布整个文件。