Skip to content

Application and container

Application coordinates Orionis startup and execution. It extends Container: the application is also the container that registers and builds services. You do not need another container for each controller or command.

IApplication defines that contract and includes IContainer operations. The instance is registered during create() and can be injected. Providers declare services, the container resolves dependencies, and HTTP/CLI kernels coordinate each request or command.

flowchart TD
    accTitle: Orionis application and container
    A[bootstrap/app.py] --> B[Application: configuration and registrations]
    B --> C[Service providers]
    C --> D[Container and lifetimes]
    B --> E[HTTP or CLI entry point]
    E --> F[Kernel and execution scope]
    F --> D
    D --> G[Controller, command or service with dependencies]

Bootstrap prepares metadata. A valid disk cache can restore it; service instances are built in each process’s memory. A container singleton is not an instance shared between workers or servers.

NeedGuide
Creation, startup and shutdownApplication lifecycle
Server and protocol integrationASGI and RSGI
Inject the application and access servicesIApplication and API
Configure the bootstrap fileBootstrap options
Define and access configurationApplication configuration
Paths and cache per deploymentDirectories and caching
Register classes and invoke callables with DIContainer and bindings and invocation
Choose transient, singleton or scopedScopes and concurrency
Organize registrations and initializationProviders
Expose a service through a facadeSync and async facades

Read .env variables exclusively in configuration files; see the independent Environment guide. During runtime, use resolved settings through app.config(). Database, Storage, HTTP and Queues have their own API guides; this section explains how the application integrates them.

Save this controller as app/http/controllers/app_info_controller.py:

from orionis.foundation.contracts.application import IApplication
from orionis.http import JSONResponse
class AppInfoController:
def __init__(self, app: IApplication) -> None:
self.app = app
async def __call__(self) -> JSONResponse:
return JSONResponse({
"name": self.app.config("app.name"),
"created": self.app.isCreated,
})

In an API route file:

from app.http.controllers.app_info_controller import AppInfoController
from orionis.support.facades import Route
Route.get("/app-info", AppInfoController)

The route passes its class to the container. Do not construct another Application inside the handler. The IApplication reference also covers method injection and the limits of shared configuration.