fangx / sqlite-driver
hyperf sqlite 驱动
v3.2.0
2021-07-19 06:38 UTC
Requires
- php: >=7.2
- ext-swoole: >=4.5
- hyperf/database: 2.*
- hyperf/utils: 2.*
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.9
- hyperf/testing: 2.1.*
- mockery/mockery: ^1.0
- phpunit/phpunit: ^9.0
Suggests
- doctrine/dbal: Required to rename columns (^3.0).
README
在hyperf中使用sqlite作为数据驱动。
SQLite不支持协程,请不要在生产环境中使用,本扩展的初衷是使用SQLite作为驱动进行单元测试。
安装
composer require fangx/sqlite-driver --dev
使用
在使用前需要配置好相关数据回滚迁移等配置,推荐使用
fangx/testing
修改 phpunit.xml
中的数据库配置
<?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="./test/bootstrap.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false"> <testsuites> <testsuite name="Tests"> <directory suffix="Test.php">./test</directory> </testsuite> </testsuites> <filter> <whitelist processUncoveredFilesFromWhitelist="true"> <directory suffix=".php">./app</directory> </whitelist> </filter> <php> <env name="DB_DRIVER" value="sqlite"/> <env name="DB_DATABASE" value=":memory:"/> </php> </phpunit>
运行测试
composer test