Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 1.01 KB

usage-with-yii-console.md

File metadata and controls

42 lines (31 loc) · 1.01 KB

Usage with Yii Console

In this example, we use yiisoft/app.

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

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'],
],
...

Now the MigrationService::class uses the View of the application that is already registered in yiisoft/view.

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