Skip to content
Antares

Boot Sequence

Application::boot() runs once per process: on every request under PHP-FPM, and once at startup under Swoole. run(), runSwoole() and runWorker() call it for you. These steps execute in order:

  1. Load .env. vlucas/phpdotenv loads environment variables from the base path, without overwriting variables that are already set. A missing .env file is not an error. Then the real environment (from Docker, systemd, your shell…) is copied into $_ENV, so a real variable always wins over .env. APP_BASE_PATH is set to the base path.

  2. Create the container. A fresh Container is created, and Router and the OpenAPI Generator are registered as singletons.

  3. Register bridge providers. Antares reads vendor/composer/installed.json and registers every provider listed under extra.antares.providers by an installed package (Monolog, Eloquent, …).

  4. Register your service providers. Each class passed to ->providers([...]) is created and its register() method is called. Because this happens after step 3, your bindings replace a bridge’s.

  5. Register routes, or load them from the cache. With APP_ENV=production and a cache whose fingerprint still matches, routes are loaded from storage/cache/routes.php and route providers are skipped. Otherwise each route provider’s register() is called, the OpenAPI controller (/openapi.json, /docs) is added unless the docs are turned off, and in production the result is written to the cache.

  6. Create the Dispatcher and ErrorHandler. Middleware is not created here: the pipeline creates it for each request.

The route cache fingerprint is computed from:

  • composer.lock
  • .env
  • All files under app/

If any of these change, the fingerprint changes and the cache is rebuilt on the next boot. Changes made anywhere else (for example a real environment variable, or routes loaded from a config/ file) are not detected; run php vendor/bin/antares cache:clear after those.