Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 950 Bytes

usage-with-yii-console.md

File metadata and controls

44 lines (32 loc) · 950 Bytes

Usage with Yii Console

In this example, we use yiisoft/app.

First, configure DI container. Create config/common/db.php with the following content:

<?php

declare(strict_types=1);

use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Sqlite\Connection as SqliteConnection;

return [
    ConnectionInterface::class => [
        'class' => SqliteConnection::class,
        '__construct()' => [
            'dsn' => 'sqlite:' . __DIR__ . '/Data/yiitest.sq3'
        ]
    ]
];

Add to config/params.php:

...
'yiisoft/db-migration' => [
    'newMigrationNamespace' => 'App\\Migration',
    'sourceNamespaces' => ['App\\Migration'],
],
...

Execute composer du in console to rebuild the configuration.

Now we have the yiisoft/db-migration package configured and it can be called in the console.

View the list of available commands with ./yii list:

./yii list