Can someone explain what a compilerpass is?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
CompilerPassimplementations are some kind of listeners that are executed after dependency injection container is built from configuration files and before it is saved as plain PHP in cache. They are used to build some structures that requires access to definitions from outer resources or need some programming that is not available in XML/YAML configuration. You can consider them as “final filters” that can modify entire DIC.Let’s consider a TwigBundle and its TwigEnvironmentPass. What it does is quite simple:
twigservice (defined as<service id="twig" class="..." ...>)twig.extensiontag. To do that you have work on complete DIC (built from XML configuration files) as those services might be defined in any bundle.As a final result the following code will be generated: