没有数据库连接的 Laravel

use*_*520 9 laravel

有没有办法在没有数据库连接的情况下使用 Laravel?我打算使用刀片和 VueJS 创建一个前端网站,该网站将使用第三方 API,而且我不需要数据库。

目前,我收到此错误,我不确定如何绕过它。

Database name seems incorrect
You're using the default database name laravel. This database does not exist.

Edit the .env file and use the correct database name in the DB_DATABASE key
Run Code Online (Sandbox Code Playgroud)

小智 12

如果您使用内部 artisan 服务作为开发服务器,则需要重新启动服务:

Ctrl + c

然后运行

php artisan serve


bis*_*hop 3

这个检查出现在 Laravel 5.6.29 中,通过 Ignition 服务的DefaultDbNameSolutionProvider.

\n\n

解决方案消息有点误导,因为它假设您想要使用数据库。它试图传达 (a) 您已配置为使用默认数据库\xe2\x80\xa0,并且 (b) 该默认数据库不存在,因此 (c) 您应该将数据库名称更改为您环境的实际价值。

\n\n

由于您没有数据库,因此进行设置后DB_DATABASE=unused您就不会再收到此错误了。当然,如果你打电话DB::connection(),那就会爆炸。但这是预料之中的。

\n\n
\n\n

\xe2\x80\xa0 Laravel 默认识别的两个数据库名称是"laravel""homestead"

\n