Documentation · Chapter 07

Install only
what the project needs.

A classic application does not have to use a database. Data therefore remains an explicit dependency.

We replace reading-list's temporary storage with SQLite without changing the application's purpose.

Prepare Data with SQLite

phpaml — zsh
aml install data --driver sqlite
aml db:show
aml data:doctor

Installation adds phpaml/data, prepares src/models, src/Data, runtime/database/migrations, runtime/database/seeders, and SQLite storage, then writes the data section to phpaml.json.

Plain model or persistent entity?

aml make:model Book

Creates a plain business class under src/models. Data is not required; nothing is persisted automatically.

aml make:entity Book

Creates a model extending AML\Data\Entity that DbSet can read and write.

Generated configuration

phpaml — zsh
"data": {
  "default": "main",
  "connections": {
    "main": {
      "driver": "sqlite",
      "database": "runtime/storage/database.sqlite"
    }
  },
  "migrations_path": "runtime/database/migrations",
  "models_path": "src/models"
}

DATA_DRIVER, DATA_DATABASE, DATA_DSN, and other DATA_* variables can override values on one installation.