vasildakov / mezzio-doctrine
Doctrine ORM integration for Mezzio
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/vasildakov/mezzio-doctrine
Requires
- php: ^8.1
- doctrine/migrations: ^3.9
- doctrine/orm: ^3.0.0
- laminas/laminas-cli: ^1.0.0
- laminas/laminas-servicemanager: ^3.3 || ^4.0
- psr/container: ^1.0 || ^2.0
- symfony/cache: ^8.0
- symfony/cache-contracts: ^3.6
- symfony/console: ^7.4
- symfony/string: ^8.0
- symfony/var-exporter: ^7.0
Requires (Dev)
- doctrine/data-fixtures: ^2.2
- ergebnis/composer-normalize: ^2.48
- friendsofphp/php-cs-fixer: ^3.93
- php-coveralls/php-coveralls: ^2.9
- phpunit/phpcov: ^10.0
- phpunit/phpunit: ^8.5 || ^9.0 || ^10.0 || ^11.0
- squizlabs/php_codesniffer: ^3.5.0
- symfony/var-dumper: ^8.0
Suggests
- doctrine/migrations: doctrine migrations if you want to keep your schema definitions versioned
README
Synopsis
Doctrine ORM integration for Mezzio. This package provides integration with Doctrine ORM 3.x, Doctrine Migrations, and Doctrine Fixtures.
Installation
Install package via composer
composer require vasildakov/mezzio-doctrine
Configuration
Include the ConfigProvider in your config aggregator:
<?php // In your config/config.php $aggregator = new ConfigAggregator([ // ... // Default App module config App\ConfigProvider::class, VasilDakov\Doctrine\ConfigProvider::class, // ... ]);
Example Configuration
<?php declare(strict_types=1); use Doctrine\DBAL\Driver\PDO\MySQL\Driver; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; return [ 'doctrine' => [ 'connection' => [ 'orm_default' => [ 'driver_class' => Driver::class, 'params' => [ 'host' => 'localhost', 'port' => '3306', 'user' => 'root', 'password' => 'root', 'dbname' => 'database', ], ], ], 'driver' => [ 'orm_default' => [ 'drivers' => [ 'App\Entity' => [ 'class' => AnnotationDriver::class, 'paths' => [ 'src/Entity', ], ], ], ], ], ], ];
Doctrine ORM Commands
orm:clear-cache:metadata Clear all metadata cache of the various cache drivers orm:clear-cache:query Clear all query cache of the various cache drivers orm:clear-cache:result Clear all result cache of the various cache drivers orm:generate-proxies [orm:generate:proxies] Generates proxy classes for entity classes orm:run-dql Executes arbitrary DQL directly from the command line orm:schema-tool:create Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output orm:schema-tool:drop Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output orm:schema-tool:update Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata orm:validate-schema Validate the mapping files
Migrations Commands
Commands uses Laminas CLI and vendor/bin/laminas entry point for it
Possible commands
doctrine:migrations:diff [diff] Generate a migration by comparing your current database to your mapping information.
doctrine:migrations:dump-schema [dump-schema] Dump the schema for your database to a migration.
doctrine:migrations:execute [execute] Execute a single migration version up or down manually.
doctrine:migrations:generate [generate] Generate a blank migration class.
doctrine:migrations:latest [latest] Outputs the latest version number
doctrine:migrations:migrate [migrate] Execute a migration to a specified version or the latest available version.
doctrine:migrations:rollup [rollup] Rollup migrations by deleting all tracked versions and insert the one version that exists.
doctrine:migrations:status [status] View the status of a set of migrations.
doctrine:migrations:up-to-date [up-to-date] Tells you if your schema is up-to-date.
doctrine:migrations:version [version] Manually add and delete migration versions from the version table.
Example
$ vendor/bin/laminas doctrine:migrations:diff
$ vendor/bin/laminas doctrine:migrations:migrate
Doctrine Fixtures Commands
doctrine:fixtures:load Load data fixtures
Tests
Run the tests with code coverage
XDEBUG_MODE=coverage vendor/bin/phpunit
Author
Vasil Dakov - vasildakov@gmail.com - https://vasildakov.com
License
Package is licensed under the MIT License - see the LICENSE file for details