webscooby/yii-cycle Cycle ORM adapter for Yii2.

Yii Cycle

Cycle ORM adapter for Yii2 framework with debug panel.

Latest Stable Version Latest Unstable Version Build Status codecov

Installation

  1. Use composer.
composer require webscooby/yii-cycle
  1. Added configuration to your configs:

use Spiral\Database\Driver\MySQL\MySQLDriver;
use Webscooby\Yii\Cycle\Provider\CacheProvider;
use Webscooby\Yii\Cycle\Factory\OrmFactory;
use Webscooby\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 <migrationName>
  • Cancel migrations
php yii migrator/down

More

  1. Spiral database configuration (DBAL)
  2. Cycle ORM Docs
1 0
1 follower
60 downloads
Yii Version: 2.0
License: MIT
Category: Database
Developed by: Lex
Created on: Apr 24, 2021
Last updated: 3 months ago
Packagist Profile
Github Repository

Related Extensions