doctrine/migrations
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
doctrine/dbal | 4.0.1 | - | MIT | prod | |
doctrine/deprecations | 1.1.3 | 7.42 kB | MIT | prod | |
doctrine/event-manager | 2.0.0 | 5.95 kB | MIT | prod | |
psr/log | 3.0.0 | 6.77 kB | MIT | prod dev | |
symfony/console | v7.0.6 | 180.99 kB | MIT | prod dev | |
symfony/stopwatch | v7.0.3 | 7.56 kB | MIT | prod dev | |
symfony/var-exporter | v7.0.6 | - | MIT | prod dev |
Doctrine/Migrations is a popular PHP package that provides additional capabilities for versioning your database schema and effectively deploying changes to it. This tool, which works atop the Database Abstraction Layer (DBAL), is both potent and user-friendly. It is an indispensable aspect of the Doctrine Project that aids developers in ensuring database schemas are consistently maintained and updated across various environments.
To get started with Doctrine/Migrations, first, ensure you have composer installed. Then proceed by pulling in the package into your PHP project using the composer require command. In command line interface, simply run:
composer require doctrine/migrations
After successfully introducing the Doctrine Migrations library into your project, you can leverage its functionality to manage your database migrations. Here's a basic example:
use Doctrine\DBAL\DriverManager;
use Doctrine\Migrations\Configuration\Connection\ExistingConnection;
use Doctrine\Migrations\Configuration\Migration\ConfigurationArray;
use Doctrine\Migrations\DependencyFactory;
$connection = DriverManager::getConnection(['url' => 'sqlite:///:memory:']);
$config = new ConfigurationArray([
'table_storage' => [
'table_name' => 'doctrine_migration_versions',
'version_column_name' => 'version',
'version_column_length' => 1024,
'executed_at_column_name' => 'executed_at',
],
'migrations_paths' => [
'MyProject\Migrations' => './migrations',
'MyProject\Component\Migrations' => './component/migrations',
],
'all_or_nothing' => true,
'check_database_platform' => true,
]);
$dependencyFactory = DependencyFactory::fromConnection($config, new ExistingConnection($connection));
// returns an instance of Doctrine\Migrations\Migration
$migration = $dependencyFactory->getMigration();
// execute a migration up
$migration->migrate();
This is just a simple demonstration and the real power of Doctrine Migrations comes with complete migration classes where you write up and down schema alterations for deployment.
The comprehensive documentation for the Doctrine/Migrations package is accessible at the Doctrine Project's official website. It provides a wealth of information covering different aspects of the tool, from installation to advanced use-cases. To dive deep into the world of Doctrine Migrations, check out the documentation by clicking here.