This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // This code is what the Symfony Dependency Injection container performs | |
| // under the hood when registering a listener. | |
| $eventDispatcher->addListener( | |
| KernelEvents::REQUEST, | |
| function ($event) { | |
| // only when here, MyListener and ExpensiveDependency trigger autoloading | |
| // and the time of calling their constructor is spent. | |
| (new MyListener(new ExpensiveDependency))->onKernelRequest($event); | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once 'vendor/autoload.php'; | |
| $functions = spl_autoload_functions(); | |
| foreach ($functions as $function) { | |
| if ($function instanceof \Closure) { | |
| $reflection = new ReflectionFunction($function); | |
| // check if autoloader closure is from laminas zendframework bridge | |
| if (str_contains($reflection->getFileName(), 'laminas-zendframework-bridge')) { |