[extension] kptlex/yii-cycle


Yii Cycle Cycle ORM adapter for Yii2 framework with debug panel.




Installation

  1. Use composer.

composer require kptlex/yii-cycle

  1. Added configuration to your configs:


use Spiral\Database\Driver\MySQL\MySQLDriver;
use Yii\Cycle\Provider\CacheProvider;
use Yii\Cycle\Factory\OrmFactory;
use Yii\Cycle\Provider\ProviderInterface;
/**
* Example mysql configuration
*/
$_dbal = [
'default' => 'mysql',
'databases' => [
'mysql' => [
'connection' => 'mysql'
]
],
'connections' => [
'mysql' => [
'driver' => MySQLDriver::class,
'options' => [
'connection' => 'mysql:host=127.0.0.1;dbname=dbname',
'username' => 'username',
'password' => 'password',
'timezone' => 'Europe/Moscow'
]
]
]
];

/**
* Example adapter configuration
*/
$config = [
'bootstrap' => [OrmFactory::class],
'container' => [
'definitions' => [
ProviderInterface::class => [
'class' => CacheProvider::class,
'dbal' => $_dbal,
'entities' => [
'@App/Entity' //namespace for your entities
],
'migrations' => [
'@App/Migration' //path or alias to your migrations
],
'migrationPath' => '@app/src/Migration', //default path or alias for new migrations
// 'migrationTable' => 'migration', //default - migration
'migrationNamespace' => 'App\\Migration' //namespace for new migrations
]
]
]
];

Migrations Use the following commands to manage migrations

  • Apply migrations

php yii migrator

  • Create migrations

php yii migrator/create

  • Cancel migrations

php yii migrator/down

More

  1. Spiral database configuration (DBAL)
  2. Cycle ORM Docs