Download the PHP package mnapoli/dbal-schema without Composer
On this page you can find all versions of the php package mnapoli/dbal-schema. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package dbal-schema
A schema manager for Doctrine DBAL: all the convenience of the Doctrine ORM, without using the ORM.
Why?
Doctrine ORM can automatically manage your DB schema based on your entity mapping. This feature is lost when using the DBAL instead of the ORM.
This package lets you achieve something similar by defining your DB schema with PHP code. It also lets you manage your database using a Symfony Console command similar to Symfony's native doctrine:schema:update
command, as well as DB migrations.
Installation
Usage
1. Define a schema
Define your DB schema by implementing the SchemaDefinition
interface:
You can read the whole API available on Doctrine's documentation.
2. Set up the schema
Doctrine can now generate/update your database based on your schema.
Using Symfony
Here is an example of configuration that can go in your config/services.yml
:
This configuration assumes your services are autowired.
Once the services are registered, you can now run the commands:
Using Silly
Using Silly you can ignore the many separate command classes and simply use the DbalSchemaCommand
class:
If you are using the Silly PHP-DI edition it's even simpler as PHP-DI can instantiate the DbalSchemaCommand
service:
3. Optional: database migrations
If you prefer using database migrations instead of running bin/console dbal:schema:update
, DBAL Schema integrates with Doctrine Migrations.
To set it up, we need the setService()
method call to happen like in the example below:
In Symfony, it can be done by installing the DoctrineMigrationsBundle and editing config/packages/doctrine_migrations.yaml
:
Now, you can run:
to generate migrations based on your DBAL schema.
All versions of dbal-schema with dependencies
doctrine/dbal Version ^2.11 || ^3.0
symfony/console Version ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0
doctrine/migrations Version ^3.0