Download the PHP package thecodingmachine/dbal-fluid-schema-builder without Composer
On this page you can find all versions of the php package thecodingmachine/dbal-fluid-schema-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thecodingmachine/dbal-fluid-schema-builder
More information about thecodingmachine/dbal-fluid-schema-builder
Files in thecodingmachine/dbal-fluid-schema-builder
Package dbal-fluid-schema-builder
Short Description Build and modify your database schema using Doctrine DBAL and a fluid syntax.
License MIT
Informations about the package dbal-fluid-schema-builder
Fluid schema builder for Doctrine DBAL
Build and modify your database schema using DBAL and a fluid syntax.
Why?
Doctrine DBAL provides a powerful API to alter your database schema. This library is a wrapper around the DBAL standard API to provide a shorter, quicker syntax for day-to-day use. It provides shortcuts and syntactic sugars to make you efficient.
IDE friendly
You can use the autocomplete of your preferred IDE (PHPStorm, Eclipse PDT, Netbeans...) to build your schema easily. No need to look at the docs anymore!
Static code analysis
Your favorite static PHP code analyzer (Scrutinizer, PHPStan...) can catch errors for you! For instance, each database type is a PHP method, so no typos anymore in the column type - ... was it 'INT' or 'INTEGER' already? :)
Why not?
The fluid schema builders aims at solving the cases you encounter in 99% of your schemas in a concise way. It does not cover the whole possible use cases and there is no aim to target that goal.
For instance, if you have foreign keys on several columns, you cannot use FluidSchema
. You should fallback to classic DBAL.
Comparison with DBAL "native" API
Instead of:
you write:
Features
FluidSchema does its best to make your life easier.
Tables and column types
Shortcut methods:
Creating indexes:
Creating unique indexes:
Make a column nullable:
Set the default value of a column:
Create a foreign key
Note: The foreign key will be automatically created on the primary table of the table "countries". The type of the "country_id" column will be exactly the same as the type of the primary key of the "countries" table.
Create a jointure table (aka associative table) between 2 tables:
Add a comment to a column:
Declare a primary key:
Declare an inheritance relationship between 2 tables:
In SQL, there is no notion of "inheritance" like with PHP objects. However, a common way to model inheritance is to write one table for the base class (containing the base columns/properties) and then one table per extended class containing the additional columns/properties. Each extended table has a primary key that is also a foreign key pointing to the base table.
The extends
method will automatically create a primary key with the same name and same type as the extended table. It will also make sure this primary key is a foreign key pointing to the extended table.
Automatic 'quoting' of table and column names
By default, the fluid-schema-builder will not quote your identifiers (because it does not know what database you use).
This means that you cannot create an item with a reserved keyword.
However, if you give to fluid-schema-builder your database platform at build time, then it will quote all identifiers by default. No more nasty surprises!
All versions of dbal-fluid-schema-builder with dependencies
doctrine/dbal Version ^3.0
doctrine/inflector Version ^1.4 || ^2.0