Configuration

Register the database service provider in the application’s services() hook. Atom uses the configured connection for migrations, queries, and models.

use Atom\Database\DatabaseServices;
use Atom\Di\ServiceProviderRegistry;

protected function services(ServiceProviderRegistry $providers): void
{
    $providers->add(DatabaseServices::fromConfig($this->getConfig(), $this->getPaths()));
}

Connection settings come from the typed DatabaseConfig options class.

For a SQLite database, set the driver and file path in .env.

DB_DRIVER=sqlite
DB_DATABASE=storage/app.sqlite

Supported driver values:

  • sqlite
  • mysql
  • mariadb
  • pgsql
  • postgres
  • postgresql

For PostgreSQL, enable the PHP pdo_pgsql extension and set DB_DRIVER=pgsql. Use the database name for DB_DATABASE and set DB_HOST, DB_PORT, DB_USERNAME, and DB_PASSWORD for your server.

Database structure follows the framework convention: migrations live in app/Database/Migrations and seeders live in app/Database/Seeders. The application registers these locations as @migrations and @seeders, so publishing bundles and database commands can use predictable paths without additional configuration.

DatabaseServices configures the Model base class during application startup, so model classes can use query(), find(), save(), and delete() without manual bootstrap code.