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 Psr\Cache\CacheItemPoolInterface;
use Sirix\Cycle\Enum\SchemaProperty;
return [
'cycle' => [
'db-config' => [
'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',
'seed-directory' => 'db/seeds',
],
'entities' => [
'src/App/src/Entity', // The 'entities' configuration must always be present and point to an existing directory, even when working with manual entities.
],
'schema' => [
'property' => SchemaProperty::GenerateMigrations,
'cache' => [
'enabled' => true,
'key' => 'cycle_cached_schema', // optional parameter
'service' => CacheItemPoolInterface::class, // optional parameter if psr container have 'cache' CacheItemPoolInterface service
]
],
],
];
// Access services using short aliases
$container->get('orm'); // Cycle\ORM\ORM
$container->get('dbal'); // Cycle\Database\DatabaseInterface
$container->get('migrator'); // Cycle\Migrations\Migrator
// Or access services using their interface names (aliases provided by ConfigProvider)
$container->get(Cycle\ORM\ORMInterface::class); // Same as $container->get('orm')
$container->get(Cycle\Database\DatabaseInterface::class); // Same as $container->get('dbal')
$container->get(Sirix\Cycle\Service\MigratorInterface::class); // Same as $container->get('migrator')
declare(strict_types=1);
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
return [
'dependencies' => [
'factories' => [
'Cache\Symfony\Filesystem' => function () {
// Create a Symfony Cache File Adapter instance
return new FilesystemAdapter(
'cycle', // Namespace prefix for cache keys
0, // Default TTL of items in seconds (0 means infinite)
'data/cycle/cache' // Absolute or relative directory for cache files storage
);
},
],
],
];