DBRelay turns a MySQL database into an instant REST API.
Run two commands:
dbrelay init
dbrelay serveDBRelay inspects your schema, detects tables and relationships, generates CRUD endpoints, and serves them through a lightweight PHP runtime.
Because building CRUD APIs is repetitive.
Every project starts with the same:
- authentication
- database setup
- CRUD endpoints
DBRelay reads your MySQL schema and automatically generates:
- Routes
- Controllers
- Query handlers
- Relationship mappings
- Instant REST API from MySQL
- Automatic schema detection
- Relationship support (
?include=) - Pagination & filtering
- Zero configuration setup
- Built-in CLI server
- OpenAPI JSON generation
- Swagger UI dashboard
- Schema inspection command
Install dependencies:
composer installdbrelay initdbrelay serve- Open
http://localhost:8000
Example:
php apps/dbrelay-cli/bin/dbrelay init
php apps/dbrelay-cli/bin/dbrelay inspect
php apps/dbrelay-cli/bin/dbrelay serveOpen the API dashboard:
http://localhost:8000/docsWith the included demo:
cd examples/mysql-demo
docker compose up -d
cd ../..
php apps/dbrelay-cli/bin/dbrelay init \
--no-interaction \
--host=127.0.0.1 \
--port=3306 \
--database=shop_db \
--username=dbrelay \
--password=dbrelay
php apps/dbrelay-cli/bin/dbrelay serveDBRelay reads your MySQL schema and automatically generates:
- Routes
- Controllers
- Query handlers
- Relationship mappings
Runtime flow:
HTTP Request
-> ZeroCore Kernel
-> Generated route
-> CRUD controller
-> DB engine query builder
-> JSON responsedbrelay init # Create .dbrelay/config.php
dbrelay inspect # Print tables and relationships
dbrelay serve # Start the generated API
dbrelay generate # Generate OpenAPI docs and route cacheBuild the CLI image:
docker build -f docker/Dockerfile -t dbrelay .
docker run --rm dbrelay --helpRun DBRelay with the MySQL demo through Docker Compose:
docker compose -f docker/docker-compose.yml up --buildThis starts MySQL, loads the sample schema, initializes DBRelay inside the app container, and serves the generated API on http://localhost:8000.
Local setup helper:
scripts/install.shStart the local development server after running dbrelay init:
scripts/dev-server.shapps/dbrelay-cli: user-facing CLI apppackages/zerocore: minimal PHP HTTP kernelpackages/db-engine: MySQL schema, relation, query, and endpoint enginepackages/openapi: OpenAPI documentation generatorexamples/mysql-demo: runnable MySQL demo databasedocs: architecture and project docs
- MySQL support: v0.1
- PostgreSQL support
- JWT authentication
- OpenAPI dashboard
- Published Docker image
- Plugin system
