Commit 39c4717e authored by nahakyuu's avatar nahakyuu

update config

parent 7b0452a0
......@@ -2,20 +2,36 @@
declare(strict_types=1);
use yiisoft\Definitions\DynamicReference;
use yiisoft\Definitions\Reference;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Mysql\ConnectionPDO;
use Yiisoft\Db\Driver\PDO\PDODriverInterface;
use Yiisoft\Db\Mysql\PDODriver;
use Yiisoft\Db\Mysql\Dsn;
/** @var array $params */
return [
ConnectionInterface::class => ConnectionPDO::class,
PDODriverInterface::class => PDODriver::class,
PDODriver::class => [
'__construct()' => [
'dsn' => $params['db']['dsn'],
'dsn' => DynamicReference::to(static fn (Dsn $dsn) => $dsn->asString()),
'username' => $params['db']['username'],
'password' => $params['db']['password'],
]
],
Dsn::class => [
'__construct()' => [
'driver' => $params['db']['driver'],
'host' => $params['db']['host'],
'databaseName' => $params['db']['databaseName'],
'port' => $params['db']['port'],
'options' => $params['db']['options']
]
]
];
......@@ -2,18 +2,6 @@
declare(strict_types=1);
use Yiisoft\Db\Mysql\Dsn;
$db = [
'driver' => 'mysql',
'host' => 'localhost',
'databaseName' => 'acdts3',
'port' => '3306',
'options' => ['charset' => 'utf8mb4'],
'username' => 'root',
'password' => 'mylittlepony',
];
return [
'app' => [
'charset' => 'UTF-8',
......@@ -26,19 +14,17 @@ return [
'yiisoft/aliases' => [
'aliases' => [
'@root' => dirname(__DIR__, 2),
'@assets' => '@root/public/assets',
'@public' => '@root/public',
'@runtime' => '@root/runtime',
'@vendor' => '@root/vendor',
],
],
'db' => array_merge($db, [
'dsn' => (new Dsn(
$db['driver'],
$db['host'],
$db['databaseName'],
$db['port'],
$db['options']
))->asString(),
]),
'db' => [
'driver' => 'mysql',
'host' => 'localhost',
'databaseName' => 'acdts3',
'port' => '3306',
'options' => ['charset' => 'utf8mb4'],
'username' => 'root',
'password' => 'mylittlepony',
]
];
......@@ -2,5 +2,15 @@
declare(strict_types=1);
use Yiisoft\Definitions\Reference;
return [
'yiisoft/aliases' => [
'aliases' => [
'@public' => '@root/public',
'@assets' => '@public/assets',
'@layout' => '@root/templates/default',
'@views' => '@root/templates/default',
],
],
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment