Checks if we have an extension.
public hasExtension ( string $name ) : boolean | ||
$name | string | The name of the extension |
return | boolean | If the extension exists |
use Symfony\Component\DependencyInjection\ContainerBuilder; // create a new container builder $container = new ContainerBuilder(); // check if your extension has already been loaded if (!$container->hasExtension('my_extension')) { // load your extension if it hasn't been loaded yet // ... }This example code shows how the hasExtension method can be used to determine whether a specific extension has already been loaded into the container. If it hasn't been loaded yet, you can load it using your own defined logic. The package library for this code is Symfony's DependencyInjection component, which provides a framework for implementing dependency injection in PHP applications.
public hasExtension ( string $name ) : boolean | ||
$name | string | The name of the extension |
return | boolean | If the extension exists |