Options & Feature Toggles#
The OptionsManager (which uses the ManagerProxy trait) lets you fine-tune how InterMix behaves.
Option toggles are configured via explicit methods.
Because this manager proxies container access, you can also call container APIs directly from it (for example get(), has(), or magic/array sugar like $opt('id') and $opt['id']).
// Using method chaining (fluent interface)
$c->options()
->setOptions( // ← the four primary flags
injection: true,
methodAttributes: true,
propertyAttributes: true,
defaultMethod: 'handle',
)
->enableLazyLoading() // ← convenience helpers
->setEnvironment('prod')
->enableDebugTracing() // collect a build trace
->end(); // back to container
1 · setOptions( injection , methodAttributes , … )#
Signature (named arguments supported)
setOptions(
bool $injection = true,
bool $methodAttributes = false,
bool $propertyAttributes = false,
?string $defaultMethod = null
): self
2 · Convenience helpers (chainable)#
Helper |
Effect |
|---|---|
|
Store class bindings as |
|
Select the active environment; used with |
|
Map interface to concrete only when |
|
Capture resolution traces for debugging. Pass |
3 · Practical primer#
Local development – verbose trace & eager loading:
container()
->options()
->setOptions(
injection: true,
methodAttributes: true,
propertyAttributes: true,
)
->enableLazyLoading(false) // eager
->enableDebugTracing() // Node-level logs
->setEnvironment('local');
Production – lazy, cached, minimal reflection:
$c = container()
->options()
->setOptions(
injection: true, // keep autowiring
methodAttributes: false, // skip attribute scanning
propertyAttributes: false,
)
->enableDebugTracing(false) // fully off (TraceLevelEnum::Off)
->enableLazyLoading(true) // default – save memory
->setEnvironment('prod')
->end();
// definition cache is configured on DefinitionManager with a PSR-6 pool
$c->definitions()->enableDefinitionCache($pool);
4 · Inspecting state#
$repo = $c->getRepository();
dump([
'environment' => $repo->getEnvironment(),
'lazy' => $repo->isLazyLoading(),
]);
Cheat-Sheet#
Four core flags live in setOptions().
Everything else is sugar via dedicated helpers.
Call ->end() to return to the container and continue the fluent chain.
See also: Environment‑specific bindings, Lazy Loading, Debug Tracing.