Yii DataBase SQLite Extension
This package provides SQLite extension for Yii DataBase library. It is used in Yii Framework but is supposed to be usable separately.
Support version
| PHP | Sqlite Version | CI-Actions |
|---|---|---|
| 7.4 - 8.0 | 3:latest |
Installation
The package could be installed via composer:
composer require yiisoft/db-sqliteConfiguration
Di-Container:
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Yiisoft\Aliases\Aliases;
use Yiisoft\Cache\ArrayCache;
use Yiisoft\Cache\CacheInterface;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Sqlite\Connection;
use Yiisoft\Log\Logger;
use Yiisoft\Log\Target\File\FileRotator;
use Yiisoft\Log\Target\File\FileRotatorInterface;
use Yiisoft\Log\Target\File\FileTarget;
use Yiisoft\Profiler\Profiler;
return [
ContainerInterface::class => static function (ContainerInterface $container) {
return $container;
},
Aliases::class => [
'@root' => dirname(__DIR__, 1), // directory / packages.
'@runtime' => '@root/runtime'
],
CacheInterface::class => static function () {
return new Cache(new ArrayCache());
},
FileRotatorInterface::class => static function () {
return new FileRotator(10);
},
LoggerInterface::class => static function (ContainerInterface $container) {
$aliases = $container->get(Aliases::class);
$fileRotator = $container->get(FileRotatorInterface::class);
$fileTarget = new FileTarget(
$aliases->get('@runtime/logs/app.log'),
$fileRotator
);
$fileTarget->setLevels(
[
LogLevel::EMERGENCY,
LogLevel::ERROR,
LogLevel::WARNING,
LogLevel::INFO,
LogLevel::DEBUG
]
);
return new Logger(['file' => $fileTarget]);
},
Profiler::class => static function (ContainerInterface $container) {
return new Profiler($container->get(LoggerInterface::class));
},
ConnectionInterface::class => static function (ContainerInterface $container) use ($params) {
$connection = new Connection(
$container->get(CacheInterface::class),
$container->get(LoggerInterface::class),
$container->get(Profiler::class),
$params['yiisoft/db-sqlite']['dsn'],
);
return $connection;
}
];Params.php
protected function params(): array
{
return [
'yiisoft/db-sqlite' => [
'dsn' => 'sqlite:' . __DIR__ . '/Data/yiitest.sq3',
]
];
}Unit testing
The package is tested with PHPUnit. To run tests:
./vendor/bin/phpunitNote: You must have SQLITE installed to run the tests, it supports all SQLITE version 3.
Mutation testing
The package tests are checked with Infection mutation framework. To run it:
./vendor/bin/infectionStatic analysis
The code is statically analyzed with Psalm. To run static analysis:
./vendor/bin/psalm

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.




