Commit 39c4717e authored by nahakyuu's avatar nahakyuu

update config

parent 7b0452a0
...@@ -2,20 +2,36 @@ ...@@ -2,20 +2,36 @@
declare(strict_types=1); declare(strict_types=1);
use yiisoft\Definitions\DynamicReference;
use yiisoft\Definitions\Reference;
use Yiisoft\Db\Connection\ConnectionInterface; use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Mysql\ConnectionPDO; use Yiisoft\Db\Mysql\ConnectionPDO;
use Yiisoft\Db\Driver\PDO\PDODriverInterface; use Yiisoft\Db\Driver\PDO\PDODriverInterface;
use Yiisoft\Db\Mysql\PDODriver; use Yiisoft\Db\Mysql\PDODriver;
use Yiisoft\Db\Mysql\Dsn;
/** @var array $params */
return [ return [
ConnectionInterface::class => ConnectionPDO::class, ConnectionInterface::class => ConnectionPDO::class,
PDODriverInterface::class => PDODriver::class, PDODriverInterface::class => PDODriver::class,
PDODriver::class => [ PDODriver::class => [
'__construct()' => [ '__construct()' => [
'dsn' => $params['db']['dsn'], 'dsn' => DynamicReference::to(static fn (Dsn $dsn) => $dsn->asString()),
'username' => $params['db']['username'], 'username' => $params['db']['username'],
'password' => $params['db']['password'], '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 @@ ...@@ -2,18 +2,6 @@
declare(strict_types=1); 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 [ return [
'app' => [ 'app' => [
'charset' => 'UTF-8', 'charset' => 'UTF-8',
...@@ -26,19 +14,17 @@ return [ ...@@ -26,19 +14,17 @@ return [
'yiisoft/aliases' => [ 'yiisoft/aliases' => [
'aliases' => [ 'aliases' => [
'@root' => dirname(__DIR__, 2), '@root' => dirname(__DIR__, 2),
'@assets' => '@root/public/assets',
'@public' => '@root/public',
'@runtime' => '@root/runtime', '@runtime' => '@root/runtime',
'@vendor' => '@root/vendor', '@vendor' => '@root/vendor',
], ],
], ],
'db' => array_merge($db, [ 'db' => [
'dsn' => (new Dsn( 'driver' => 'mysql',
$db['driver'], 'host' => 'localhost',
$db['host'], 'databaseName' => 'acdts3',
$db['databaseName'], 'port' => '3306',
$db['port'], 'options' => ['charset' => 'utf8mb4'],
$db['options'] 'username' => 'root',
))->asString(), 'password' => 'mylittlepony',
]), ]
]; ];
...@@ -2,5 +2,15 @@ ...@@ -2,5 +2,15 @@
declare(strict_types=1); declare(strict_types=1);
use Yiisoft\Definitions\Reference;
return [ 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