contenir / contenir-db-model-tools
Command-line tools for contenir-db-model: generate entities from live tables, upgrade 1.x entities and validate mappings
Package info
github.com/contenir/contenir-db-model-tools
pkg:composer/contenir/contenir-db-model-tools
Requires
- php: ~8.3.0 || ~8.4.0 || ~8.5.0
- contenir/contenir-db-model: ^2.0@RC
- nette/php-generator: ^4.1
- nikic/php-parser: ^5.0
- psr/container: ^1.1 || ^2.0
- symfony/console: ^7.0.8
Requires (Dev)
- mikey179/vfsstream: ^1.6.12
- php-db/phpdb-mysql: ^0.4.0
- php-db/phpdb-pgsql: 0.1.x-dev
- php-db/phpdb-qa-tools: 0.1.x-dev
- php-db/phpdb-sqlite: ^0.2.0
- phpunit/phpunit: ^11.5.42
Suggests
- laminas/laminas-cli: Run the commands through an application's container and configured adapter
- php-db/phpdb-mysql: Read MySQL schemas
- php-db/phpdb-pgsql: Read PostgreSQL schemas
- php-db/phpdb-sqlite: Read SQLite schemas
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-07 03:58:28 UTC
README
Command-line tools for contenir-db-model 2.x:
entity:generatewrites typed, attribute-mapped entity classes from live database tables.entity:upgradeconverts contenir-db-model 1.x entities (AbstractEntitywith$columnsarrays) to 2.x attributes in place.mapping:validatechecks entity mappings against the live schema. It catches missing columns, nullability and type drift, and key mismatches, so you can use it in CI.
They work with MySQL, PostgreSQL and SQLite through php-db/phpdb.
Requirements
- PHP 8.3, 8.4 or 8.5
contenir/contenir-db-model2.x- The phpdb platform package for your database:
php-db/phpdb-mysql,php-db/phpdb-pgsqlorphp-db/phpdb-sqlite
Installation
composer require --dev contenir/contenir-db-model-tools:^1.0@RC php-db/phpdb-mysql
Until php-db/phpdb 0.6.0 and contenir-db-model 2.0.0 are tagged, the
project needs "minimum-stability": "dev" and "prefer-stable": true.
Usage
Standalone, with a DSN:
vendor/bin/db-model entity:generate --all --dsn "mysql://app:secret@127.0.0.1/app" vendor/bin/db-model entity:upgrade src/Entity --dsn "$DATABASE_URL" vendor/bin/db-model mapping:validate --path src/Entity --dsn "$DATABASE_URL"
Through laminas-cli, the commands are db-model:entity:generate,
db-model:entity:upgrade and db-model:mapping:validate. They use your
application's contenir_db_model.adapter, so --dsn is optional:
vendor/bin/laminas db-model:mapping:validate --path src/Entity
Documentation
- Setup and connections: DSNs, laminas-cli and exit codes
- Generating entities:
entity:generate, the type map and relation inference - Upgrading 1.x entities:
entity:upgrade, what changes and what to check afterwards - Validating mappings:
mapping:validateand every check it runs llms.txt: a condensed reference for LLMs
Development
composer install composer check # Mago lint and analysis, then the unit and integration suites (SQLite) composer test-integration # integration suite only, SQLite by default
The integration suite also runs against MySQL and PostgreSQL. Start them
with docker compose up -d, then run:
DB_PLATFORM=mysql DB_PORT=33306 DB_PASSWORD=secret composer test-integration DB_PLATFORM=pgsql DB_PORT=55432 DB_USER=postgres DB_PASSWORD=secret composer test-integration
License
BSD-3-Clause. See LICENSE.md.