Returns the compiler.
public getCompiler ( ) : |
||
return | The compiler |
use Symfony\Component\DependencyInjection\ContainerBuilder; use MyBundle\DependencyInjection\MyBundleCompilerPass; $container = new ContainerBuilder(); $container->addCompilerPass(new MyBundleCompilerPass()); $compiler = $container->getCompiler(); $compiler->compile();
use Symfony\Component\DependencyInjection\ContainerBuilder; use MyBundle\DependencyInjection\MyBundleExtension; $container = new ContainerBuilder(); $extension = new MyBundleExtension(); $extension->load([], $container); $compiler = $container->getCompiler(); $compiler->compile();In this example, we create a new instance of the ContainerBuilder class, and add a custom extension (MyBundleExtension) to it. We then load this extension into the container using the load method, and get an instance of the Compiler class using the getCompiler method. We then call the compile method to optimize the container. Overall, the Symfony\Component\DependencyInjection\ContainerBuilder is a powerful and flexible package library for PHP that makes it easy to configure and manage dependencies in your applications.
public getCompiler ( ) : |
||
return | The compiler |