Laravel 在测试时无法连接到 sqlite 并使用开发 postgresql 设置
Posted
技术标签:
【中文标题】Laravel 在测试时无法连接到 sqlite 并使用开发 postgresql 设置【英文标题】:Laravel fails to connect into sqlite when in testing and uses the development postgresql settings 【发布时间】:2019-11-07 03:18:51 【问题描述】:我有以下phpunit
测试:
namespace Test\Database\Integration\Repositories;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Repositories\RoverRepository;
use App\Model\Rover;
use App\Model\Grid;
class RoverRepositoryTest extends TestCase
use RefreshDatabase;
/**
* Undocumented variable
*
* @var RoverRepository|null
*/
private $repository=null;
/**
* Undocumented variable
*
* @var Grid|null;
*/
private $grid=null;
public function setUp(): void
parent::setUp();
$this->runDatabaseMigrations();
$grid=factory(Grid::class)->create([
'width'=>5,
'height'=>5
]);
$rover=factory(Rover::class, 5)->create([
'grid_id' => $grid->id,
'grid_pos_x' => rand(0, $grid->width),
'grid_pos_y' => rand(0, $grid->height),
]);
$this->grid=$grid;
//How do I run Migrations and generate the db?
$this->repository = new RoverRepository();
public function tearDown(): void
parent::tearDown();
//How do I nuke my Database?
/**
* Testing Base Search
*
* @return void
*/
public function testBasicSearch(): void
$this->assertTrue(true);
而我的phpunit.xml
设置为:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Database">
<directory suffix="Test.php">./tests/Database</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DATABASE_URL" value="localhost"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>
但由于某种原因,当我使用以下命令启动测试时:
1) Test\Database\Integration\Repositories\RoverRepositoryTest::testBasicSearch
Illuminate\Database\QueryException: SQLSTATE[08006] [7] FATAL: password authentication failed for user "laravel" (SQL: select tablename from pg_catalog.pg_tables where schemaname = 'public')
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php:108
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php:35
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:79
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:46
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:576
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
/var/www/html/vendor/symfony/console/Command/Command.php:255
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
/var/www/html/vendor/symfony/console/Application.php:921
/var/www/html/vendor/symfony/console/Application.php:273
/var/www/html/vendor/symfony/console/Application.php:149
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:182
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:275
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:136
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:220
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:56
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:55
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:18
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:105
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:72
/var/www/html/tests/Database/Integration/Repositories/RoverRepositoryTest.php:31
Caused by
PDOException: SQLSTATE[08006] [7] FATAL: password authentication failed for user "laravel"
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:46
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php:33
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:182
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:918
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:943
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:399
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:325
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php:108
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php:35
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:79
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:46
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:576
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
/var/www/html/vendor/symfony/console/Command/Command.php:255
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
/var/www/html/vendor/symfony/console/Application.php:921
/var/www/html/vendor/symfony/console/Application.php:273
/var/www/html/vendor/symfony/console/Application.php:149
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:182
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:275
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:136
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:220
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:56
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:55
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:18
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:105
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:72
/var/www/html/tests/Database/Integration/Repositories/RoverRepositoryTest.php:31
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
对于生产设置,我将以下 .env
文件用于 thw 数据库:
DB_CONNECTION=pgsql
DB_HOST=postgresql
DB_PORT=5432
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=IDontTellYouThisIsNotAnActuallPassword
所以我有两个问题:
为什么我的 sqlite 设置被导入? 如何在测试时强制使用 inmemory sqlite?编辑 1
我制作了一个名为.env.testing
的文件:
DB_CONNECTION=sqlite
DATABASE_URL=localhost
DB_DATABASE=:memory:
并将我的phpunit.xml
更改为:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Database">
<directory suffix="Test.php">./tests/Database</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
</php>
</phpunit>
laravel 中 sqlite 的设置还有:
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
编辑 2
我按照建议尝试了:
namespace Test\Database\Integration\Repositories;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use App\Repositories\RoverRepository;
use App\Model\Rover;
use App\Model\Grid;
class RoverRepositoryTest extends TestCase
use RefreshDatabase;
use DatabaseMigrations;
/**
* Undocumented variable
*
* @var RoverRepository|null
*/
private $repository=null;
/**
* Undocumented variable
*
* @var Grid|null;
*/
private $grid=null;
public function setUp(): void
parent::setUp();
$this->runDatabaseMigrations();
$grid=factory(Grid::class)->create([
'width'=>5,
'height'=>5
]);
$rover=factory(Rover::class, 5)->create([
'grid_id' => $grid->id,
'grid_pos_x' => rand(0, $grid->width),
'grid_pos_y' => rand(0, $grid->height),
]);
$this->grid=$grid;
//How do I run Migrations and generate the db?
$this->repository = new RoverRepository();
public function tearDown(): void
parent::tearDown();
//How do I nuke my Database?
/**
* Testing Base Search
*
* @return void
*/
public function testBasicSearch(): void
$this->assertTrue(true);
然后我运行以下命令:
php artisan config:clear
php artisan config:clear --env=testing
php artisan config:clear --env=development
php artisan config:cache
错误仍然存在。
编辑 3
经过大量测试后,我清空了.env
文件。然后我运行命令:
php artisan config:cache
而且错误变成了:
PHPUnit 7.5.13 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 111 ms, Memory: 18.00 MB
There was 1 error:
1) Test\Database\Integration\Repositories\RoverRepositoryTest::testBasicSearch
Mockery\Exception\BadMethodCallException: Received Mockery_1_Illuminate_Console_OutputStyle::askQuestion(), but no expectations were specified
/var/www/html/vendor/symfony/console/Style/SymfonyStyle.php:222
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:332
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/ConfirmableTrait.php:31
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:34
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:576
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
/var/www/html/vendor/symfony/console/Command/Command.php:255
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
/var/www/html/vendor/symfony/console/Application.php:921
/var/www/html/vendor/symfony/console/Application.php:273
/var/www/html/vendor/symfony/console/Application.php:149
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:182
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:275
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:136
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:220
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:56
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:55
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:18
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:105
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:72
另外,如果我只保留 sqlite 设置并恢复到原来的 .env
,我会收到错误:
PHPUnit 7.5.13 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 115 ms, Memory: 18.00 MB
There was 1 error:
1) Test\Database\Integration\Repositories\RoverRepositoryTest::testBasicSearch
InvalidArgumentException: Database [pgsql] not configured.
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:152
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:115
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:86
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:77
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/FreshCommand.php:46
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:576
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
/var/www/html/vendor/symfony/console/Command/Command.php:255
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
/var/www/html/vendor/symfony/console/Application.php:921
/var/www/html/vendor/symfony/console/Application.php:273
/var/www/html/vendor/symfony/console/Application.php:149
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:182
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:275
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:136
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:220
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:56
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseMigrations.php:16
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:109
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:72
这意味着如果提供了.env
,.env.testing
将被完全忽略。
【问题讨论】:
【参考方案1】:在实现 SQLite 数据库进行测试时,不需要指定数据库 URL,因为它是在内存中运行的。
从 phpunit.xml 中删除该行
<env name="DATABASE_URL" value="localhost"/>
您的配置可能正在缓存。运行命令
php artisan config:clear
现在重新运行测试。
从 setUp() 函数中删除代码
$this->runDatabaseMigrations();
要迁移SQLite中的数据库,可以使用
use Illuminate\Foundation\Testing\DatabaseMigrations;
编辑:对于 config/database.php
使用SQLite需要在database.php中进行配置。
//config/database.php
...
'sqlite' => [
'driver' => 'sqlite',
'database' => storage_path('database/database.sqlite'),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
...
【讨论】:
我删除了$this->runDatabaseMigrations();
并使用了use Illuminate\Foundation\Testing\DatabaseMigrations;
,但错误仍然存在。
尝试从config/database.php中删除sqlite的url键值【参考方案2】:
您的测试似乎仍在使用 sql 数据库。
在使用 SQLite 数据库进行测试时,我建议您验证以下内容:
你的database.sqlite必须在database文件夹下创建,别忘了调整文件权限。
您必须包含以下 2 个特征:
// this trait is used to wrap every query in a transaction where this one will be deleted at the end of the test
use DatabaseTransactions;
// this one allow Laravel to prepare the database
use DatabaseMigrations;
如果还是不行,我建议你停止你的服务器,执行当前的工匠命令php artisan config:clear
并重新启动它。
编辑
我刚刚看到你的 phpunit.xml 包含一些错误,删除所有 env 标签并只添加这些:
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
不需要创建 .env.testing
【讨论】:
刚刚看到你的 XML 文件,我已经编辑了我的答案,现在应该可以正常工作了 保持.env
的这些设置仍然存在。【参考方案3】:
确保您的 .env 文件与您的数据库具有相同的密码。
【讨论】:
但是在sqlite
上没有这样的密码选项,而在 postgresql 上有。
你如何登录到你的数据库?【参考方案4】:
我遇到了同样的问题。
我搜索并看到了这个主题。
我想把答案放在以后的搜索中。
我尝试了很多东西,过了一段时间,我明白在我的新 linux 操作系统上,我没有安装sqlite driver
。
sudo apt-get install php-sqlite
在 Windows 上,只需删除 php.ini
中的 SQLite 扩展名,方法是删除该行之前的分号 ;
。
所以问题简单地解决了。
【讨论】:
【参考方案5】:您是否使用与.env
中指定的名称非常相同的任何环境变量?有时这些可能会导致与.env
中指定的内容发生巨大冲突。
在您的情况下,可能是通过将Homestead
或docker
与docker-compose
一起使用,在这些情况下设置一个唯一的前缀来标识它的使用是个好主意。例如,不使用 DB_CONNECTION
之类的名称,将其命名为 DOCKER_DB_CONNECTION
,因此完全没有冲突。
如果是docker-compose
,这也是个坏主意:
version: '3.1'
services:
develop:
image: ddesyllas/php-dev:dev-n-build
volumes:
- ".:/var/www/html"
- "./.laravel.env:/var/www/html/.env"
links:
- memcache
environment:
DB_CONNECTION: pgsql
DB_HOST : postgresql
DB_PORT : 5432
DB_DATABASE: $DOCKER_POSTGRES_DB
DB_USERNAME: $DOCKER_POSTGRES_USER
DB_PASSWORD: $DOCKER_POSTGRES_PASSWORD
nginx:
image: nginx:alpine
ports:
- 7880:7880
links:
- "develop:develop"
volumes:
- ".:/var/www/html"
- "./docker/nginx.conf:/etc/nginx/nginx.conf:ro"
postgresql:
image: postgres:alpine
volumes:
- './docker/misc_volumes/postgresql:/var/lib/postgresql/data'
environment:
POSTGRES_USER: $DOCKER_POSTGRES_USER
POSTGRES_DB: $DOCKER_POSTGRES_DB
POSTGRES_PASSWORD: $DOCKER_POSTGRES_PASSWORD
memcache:
image: memcached:alpine
改为使用以下docker-compose.yml
中指定的环境变量名称是个好主意:
version: '3.1'
services:
develop:
image: ddesyllas/php-dev:dev-n-build
volumes:
- ".:/var/www/html"
- "./.laravel.env:/var/www/html/.env"
links:
- memcache
environment:
DOCKER_DB_CONNECTION: pgsql
DOCKER_DB_HOST : postgresql
DOCKER_DB_PORT : 5432
DOCKER_DB_DATABASE: $DOCKER_POSTGRES_DB
DOCKER_DB_USERNAME: $DOCKER_POSTGRES_USER
DOCKER_DB_PASSWORD: $DOCKER_POSTGRES_PASSWORD
nginx:
image: nginx:alpine
ports:
- 7880:7880
links:
- "develop:develop"
volumes:
- ".:/var/www/html"
- "./docker/nginx.conf:/etc/nginx/nginx.conf:ro"
postgresql:
image: postgres:alpine
volumes:
- './docker/misc_volumes/postgresql:/var/lib/postgresql/data'
environment:
POSTGRES_USER: $DOCKER_POSTGRES_USER
POSTGRES_DB: $DOCKER_POSTGRES_DB
POSTGRES_PASSWORD: $DOCKER_POSTGRES_PASSWORD
memcache:
image: memcached:alpine
你有没有注意到我像这样重命名了环境变量:
DB_CONNECTION => DOCKER_DB_CONNECTION DB_HOST => DOCKER_DB_HOST DB_PORT => DOCKER_DB_PORT DB_DATABASE => DOCKER_DB_DATABASE DB_USERNAME => DOCKER_DB_USERNAME DB_PASSWORD => DOCKER_DB_PASSWORD【讨论】:
以上是关于Laravel 在测试时无法连接到 sqlite 并使用开发 postgresql 设置的主要内容,如果未能解决你的问题,请参考以下文章
AttributeError:使用flask-sqlalchemy连接到sqlite数据库时无法设置属性
在 000webhost 上托管时无法使用 jwt 连接到 laravel api
Laravel Dusk 错误:无法连接到 localhost 端口 9515:连接被拒绝