PHP code example of sirix / cycle-orm-factory
1. Go to this page and download the library: Download sirix/cycle-orm-factory library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sirix / cycle-orm-factory example snippets
declare(strict_types=1);
use Cycle\Database\Config;
use Sirix\Cycle\Enum\SchemaProperty;
return [
'cycle' => [
'default' => 'default',
'databases' => [
'default' => [
'connection' => 'mysql',
]
],
'connections' => [
'mysql' => new Config\MySQLDriverConfig(
connection: new Config\MySQL\TcpConnectionConfig(
database: 'cycle-orm',
host: '127.0.0.1',
port: 3306,
user: 'cycle',
password: 'password'
),
reconnect: true,
timezone: 'UTC',
queryCache: true,
),
]
],
'migrator' => [
'directory' => 'db/migrations',
'table' => 'migrations'
],
'entities' => [
'src/App/src/Entity',
],
'schema' => [
'property' => SchemaProperty::GenerateMigrations,
'cache' => true,
'directory' => 'data/cache'
],
];
'migrator' => [
'directory' => 'db/migrations',
'table' => 'migrations',
],
'entities' => [
'src/App/src/Entity',
],
'schema' => [
'property' => null,
'cache' => true,
'directory' => 'data/cache'
],
$container->get('orm'); // Cycle\ORM\ORM
$container->get('dbal'); // Cycle\Database\DatabaseInterface
$container->get('migrator'); // Cycle\Migrations\Migrator
bash
php vendor/bin/laminas migrator:migrate
bash
php vendor/bin/laminas migrator:rollback