PHP code example of ezsystems / doctrine-dbal-schema
1. Go to this page and download the library: Download ezsystems/doctrine-dbal-schema 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/ */
ezsystems / doctrine-dbal-schema example snippets
use EzSystems\DoctrineSchema\API\Event\SchemaBuilderEvent;
use EzSystems\DoctrineSchema\API\Event\SchemaBuilderEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class BuildSchemaSubscriber implements EventSubscriberInterface
{
/**
* @var string
*/
private $schemaFilePath;
public function __construct(string $schemaFilePath)
{
$this->schemaFilePath = $schemaFilePath;
}
/**
* Returns an array of events this subscriber wants to listen to.
*
* @return string[]
*/
public static function getSubscribedEvents()
{
return [
SchemaBuilderEvents::BUILD_SCHEMA => ['onBuildSchema', 200],
];
}
/**
* @param \EzSystems\DoctrineSchema\API\Builder\SchemaBuilderEvent $event
*/
public function onBuildSchema(SchemaBuilderEvent $event)
{
$event
->getSchemaBuilder()
->importSchemaFromFile($this->schemaFilePath);
}
}
public function __construct(SchemaBuilder $schemaBuilder)
{
$this->schemaBuilder = $schemaBuilder;
}
public function importSchema()
{
$schema = $this->schemaBuilder->buildSchema();
// ...
}