Other frameworks and plain PHP
Any PHP framework, or none: your own kernel and behavior classes that take dependencies from a PSR-11 container.
Without a bridge, you write the kernel yourself and initialize it in your front controller, as shown in Getting started. To give behavior classes access to the services of your application, attach its PSR-11 container as a delegate of the kernel’s container (AspectContainer):
protected function configureAop(AspectContainer $container): void{ // Runs when one of its behaviors first runs, after the application container is attached $container->addLazyService( MonitorAspect::class, static fn(AspectContainer $container) => new MonitorAspect($container->getService(LoggerInterface::class)), ); // or take the whole behavior class from the application container, by the id it has there // $container->addLazyService(MonitorAspect::class, static fn(AspectContainer $c) => $c->get('app.monitor_aspect'));}// Once the application container exists, e.g. right after the framework kernel has bootedApplicationAspectKernel::getInstance()->getContainer()->setDelegate($psrContainer);get(), getService() and has() of the kernel’s container fall back to the delegate for ids it doesn’t know. The kernel is initialized before the application builds its container, so you register behavior classes as usual and they resolve their dependencies lazily. The compile step and the cache warm-up only need the behavior class itself, so they run before setDelegate() and never create an instance of it. A dependency that is still missing when the factory runs throws ServiceNotFoundException.
- A factory never asks the kernel’s container for its own id: that id resolves to the behavior class being built.
- Behavior classes are never discovered in the delegate, because a PSR-11 container can’t be introspected. Register every behavior class in
configureAop(). A bridge for a specific framework can collect services by tag or interface and register them withaddLazyService(). - Creating a behavior class must not run one of its own behaviors. The interceptor reports that case with an
AspectCircularReferenceException.
All kernel options, the Features flags and the vendor/bin/aspect commands are in Configuration. The deployment recipe is in Production.
© 2026 Alexander Lisachenko
