Skip to content

Databases and services ​

A project declares the services it needs, and dqx runs them:

yaml
services: [db, redis, mailpit]

Where they are, from two sides ​

The same service has two addresses, and mixing them up is the most common local-development mistake.

From inside the application — this is what belongs in .env:

ini
DB_HOST=db
REDIS_HOST=redis
MAIL_HOST=mailpit

Service names on the project's own network. They do not change.

From your machine — this is what a GUI client needs:

bash
dqx db --url
# mysql://user:pass@127.0.0.1:60082/my_app

An ephemeral port, chosen when the project started, different after the next dqx up. That is deliberate: fixed host ports mean two projects cannot run at once. dqx info lists them all.

Do not put the host port in .env

It is right until the next restart. The application should use the service name; only tools running on your machine need the port.

The database ​

Schemas and the project's user are created on every install, not only the first. A container's own initialisation runs once, ever — so a schema added later, or a password changed later, would leave an application unable to connect with nothing saying why.

bash
dqx db                  # a client
dqx db --url            # today's URL
dqx db:import dump.sql  # and db:export
dqx snapshot            # database and storage together
dqx restore

A project can declare more than one schema, and a project serving several sites gives each its own.

Mail ​

mailpit catches everything the application sends and shows it in a browser — dqx info prints the URL. Nothing leaves the machine, which is the point.

Search and cache ​

redis, meilisearch and elasticsearch are declared the same way. Each is only started for a project that asks for it, and a site can opt out of a service the project runs — which matters more than it sounds: an Elasticsearch container costs roughly a gigabyte, and it is worth not paying for it four times in a project where two sites use it.

yaml
sites:
  - domains: { primary: api.example.test }
    services: [db, redis]        # this site's, out of the project's

Daemons ​

A queue worker or a scheduler is a long-running process, not a service:

yaml
daemons:
  - name: horizon
    command: php artisan horizon

dqx runs it beside the application, on the same image. It is not waited for at startup — a worker cannot be healthy before the application it runs exists, which on a fresh install has not been installed yet.

Declare the package too

A worker whose package is not installed restarts forever while every page answers 200. dqx doctor reports the loop, but the fix is to install what the command needs.

dqx v1.1.0