Download the PHP package zero-to-prod/db-model without Composer
On this page you can find all versions of the php package zero-to-prod/db-model. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zero-to-prod/db-model
More information about zero-to-prod/db-model
Files in zero-to-prod/db-model
Package db-model
Short Description Generates PHP Artifacts to Represent Database Schemas
License MIT
Informations about the package db-model
Db Model
Generates PHP artifacts to represent database schemas.
This is useful if you want a single source of truth for your database schema that you can reference in your codebase.
Install the package with db-model:install.
Scaffold PHP representation of your database tables with db-model:generate.
Check them with db-model:check.
Requirements
- PHP
^8.5 - Laravel 13
- MySQL 8
Installation
Configuration
CLI install:
Rerunning it is safe.
To publish the configuration file by itself instead:
namespace and path must describe the same place: a directory holding one
subdirectory per schema, named after it.
Usage
Scaffold a table enum beside it for every table in the database:
rules() states only what the schema itself constrains. Uniqueness,
confirmation and any format the database does not enforce belong to the
request:
Interfaces
implements names an interface every generated table enum declares — a single
class-string, or a list of them. It defaults to null, which declares none:
The generator writes the clause and the imports it needs. Satisfying the
interface is yours to do, on the trait above.
Checking for drift
Add the check to your pipeline. It names every difference and exits non-zero:
Both commands take --schema to select the schema, defaulting to App, plus
--connection and --database to say where to read it from. Without them the
default connection and its own database are read:
Agent development
The package registers an MCP server so
coding agents can read how it is meant to be used. It requires
laravel/mcp, and registers nothing without
it.
Register it with your agent:
Three tools are exposed:
readme— this document.api— the exact signature of every public class, property and method. Anything unlisted is internal and may change in any release.install— whatdb-model:installdoes, without a prompt to answer. Every argument defaults to the current setting,databasesto the connection's own database. An unknown database name is answered with the list of real ones, and aconfig/db-model.phpthat says something else is left alone and reported until the call passesoverwrite: true.
Point the handle somewhere else, or turn the server off, in
config/db-model.php:
Development
composer check requires a coverage driver (Xdebug or pcov); without one Pest
cannot satisfy the --min=100 gate.
The tests read a real MySQL schema. They create the database named by
DB_DATABASE if it does not exist, and drop every table in it. Point them at a
throwaway database — phpunit.xml defaults to testing_db_model on
127.0.0.1:3306:
License
MIT. See LICENSE.
All versions of db-model with dependencies
illuminate/console Version ^13.0
illuminate/database Version ^13.0
illuminate/support Version ^13.0