Yii Cycle ¶Cycle ORM adapter for Yii2 framework with debug panel.
Installation ¶
- Use composer.
composer require kptlex/yii-cycle
- 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 ¶