1. Go to this page and download the library: Download cycle/schema-builder 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/ */
cycle / schema-builder example snippets
use Cycle\Migrations;
use Cycle\Database;
use Cycle\Database\Config;
$dbal = new Database\DatabaseManager(new Config\DatabaseConfig([
'default' => 'default',
'databases' => [
'default' => [
'connection' => 'sqlite'
]
],
'connections' => [
'sqlite' => new Config\SQLiteDriverConfig(
connection: new Config\SQLite\MemoryConnectionConfig(),
queryCache: true,
),
]
]));
$registry = new \Cycle\Schema\Registry($dbal);
use Cycle\Schema\Definition;
$entity = new Definition\Entity();
$entity
->setRole('user')
->setClass(User::class);
// add fields
$entity->getFields()
->set('id', (new Definition\Field())->setType('primary')->setColumn('id')->setPrimary(true))
->set('name', (new Definition\Field())->setType('string(32)')->setColumn('user_name'));
// register entity
$r->register($entity);
// associate table
$r->linkTable($entity, 'default', 'users');
use Cycle\Schema\Compiler;
$schema = (new Compiler())->compile($r);
$orm = $orm->with(schema: new \Cycle\ORM\Schema($schema));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.