Expand description
Facade-style ambient helpers.
Inside a request task, these resolve the request-scoped Container
installed by inject_container_mw and hand you the underlying service.
Outside a request (e.g. in main.rs before the server starts) they
panic — use Container directly in that case.
Laravel’s Cache::put(), Mail::to(), DB::connection() etc. work this
way: an ambient container resolves the right concrete implementation
without each call site having to plumb a $container reference.
Anvilforge’s version is opt-in — handlers that take State<Container>
work just as well, and the explicit signature is recommended in
library code.
Functions§
- app
- The current request’s container. Panics outside a request task.
- cache
- Default cache store.
- config
- Application config (
APP_NAME,APP_ENV,APP_KEY,APP_URL, …). - db
- Default DB driver pool.
let users = User::query().get(&db()).await?; - events
- Event bus.
- mailer
- Default mailer.
- queue
- Default queue.
- storage
- Storage manager.