use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; class MyController extends AbstractActionController { public function indexAction() { $pluginManager = $this->getPluginManager(); $pluginManager->setInvokableClass('myplugin', 'MyPlugin'); $myPlugin = $pluginManager->get('myplugin'); // Use $myPlugin here // ... return new ViewModel(); } }
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpKernel\Controller\ControllerResolver; use Symfony\Component\HttpKernel\HttpKernel; $request = Request::createFromGlobals(); $controllerResolver = new ControllerResolver(); $argumentResolver = new ArgumentResolver(); $pluginManager = $this->getPluginManager(); $kernel = new HttpKernel($controllerResolver, $argumentResolver, $pluginManager); $response = $kernel->handle($request); $response->send();This example shows how to use the getPluginManager method in a Symfony application to load plugins for the HttpKernel component and handle an HTTP request. Here, the HttpKernel is initialized with the controller resolver, argument resolver and plugin manager, and the handle() method is called to process the request. Package/library: Symfony Framework