|
4 | 4 | Container Building Workflow |
5 | 5 | =========================== |
6 | 6 |
|
7 | | -In the preceding pages of this section of the componentsthere has been |
8 | | -little to saywhere the various files and classes should be located. This |
9 | | -is because thisdepends on the application, library or framework you want |
10 | | -to usethe container in. Looking at how the container is configured and built |
11 | | -in theSymfony2 full stack framework will help you see how this all fits |
12 | | -togetherwhether you are using the full stack framework or looking to use |
13 | | -the servicecontainer in another application. |
| 7 | +In the preceding pages of this section,there has been little to say about |
| 8 | +where the various files and classes should be located. This is because this |
| 9 | +depends on the application, library or frameworkin whichyou want to use |
| 10 | +the container. Looking at how the container is configured and built in the |
| 11 | +Symfony2 full stack framework will help you see how this all fits together, |
| 12 | +whether you are using the full stack framework or looking to use the service |
| 13 | +container in another application. |
14 | 14 |
|
15 | 15 | The full stack framework uses the ``HttpKernel`` component to manage the loading |
16 | | -of service container configuration from theapp levelandfrombundlesas well |
17 | | -as with the compilation and caching. Even if you are not usingthe``HttpKernel`` |
18 | | -it should give you an idea ofa way oforganising configuration in a modular |
| 16 | +oftheservice container configuration from theapplicationand bundlesand |
| 17 | +also handles the compilation and caching. Even if you are not using ``HttpKernel``, |
| 18 | +it should give you an idea ofone way oforganizing configuration in a modular |
19 | 19 | application. |
20 | 20 |
|
21 | | -Working with cachedcontainer |
| 21 | +Working with cachedContainer |
22 | 22 | ----------------------------- |
23 | 23 |
|
24 | | -Before building the container a cached version is checked for. The ``HttpKernel`` |
25 | | -has a debug setting, if this is false then the cached version is used if it |
26 | | -exists. If debug is true then the:doc:`cached configuration is checked for freshness<components/config/caching>` |
27 | | -and the cached version of the container used if it is. If not then the container |
28 | | -is built from the app level configuration and the bundle's extension configuration. |
| 24 | +Before building it, the kernel checks to see if a cached version of the container |
| 25 | +exists. The ``HttpKernel`` has a debug setting and if this is false, the |
| 26 | +cached version is used if it exists. If debug is true then the kernel |
| 27 | +:doc:`checks to see if configuration is fresh<components/config/caching>` |
| 28 | +and if it is, the cached version of the container is. If not then the container |
| 29 | +is built from the application-level configuration and the bundles's extension |
| 30 | +configuration. |
| 31 | + |
29 | 32 | Read:ref:`Dumping the Configuration for Performance<components-dependency-injection-dumping>` |
30 | 33 | for more details. |
31 | 34 |
|
32 | | -Applicationlevelconfiguration |
| 35 | +Application-levelConfiguration |
33 | 36 | ------------------------------- |
34 | 37 |
|
35 | 38 | Application level config is loaded from the ``app/config`` directory. Multiple |
36 | 39 | files are loaded which are then merged when the extensions are processed. This |
37 | | -allows for differentconfig for different environments e.g. dev, prod. |
| 40 | +allows for differentconfiguration for different environments e.g. dev, prod. |
38 | 41 |
|
39 | | -These files contain parameters and servicesto be loaded directly into |
| 42 | +These files contain parameters and servicesthat are loaded directly into |
40 | 43 | the container as per:ref:`Setting Up the Container with Configuration Files<components-dependency-injection-loading-config>`. |
41 | | -They all contain config to be processed by extensions as per:ref:`Managing Configuration with Extensions<components-dependency-injection-extension>`. |
| 44 | +They also contain configuration that is processed by extensions as per |
| 45 | +:ref:`Managing Configuration with Extensions<components-dependency-injection-extension>`. |
42 | 46 | These are considered to be bundle configuration since each bundle contains |
43 | 47 | an Extension class. |
44 | 48 |
|
45 | | -Bundlelevelconfig withextensions |
46 | | ------------------------------------ |
| 49 | +Bundle-levelConfiguration withExtensions |
| 50 | +------------------------------------------ |
47 | 51 |
|
48 | | -By convention each bundle contains an Extension class which is in the bundle's |
49 | | -Dependency Injection directory. These are registered with the ``ContainerBuilder`` |
50 | | -when theKernel is booted. When the ContainerBuilder is:doc:`compiled<components/dependency-injection/compilation>` |
51 | | -theapplevelconfig relevant to the bundle's extension is passed to the Extension |
52 | | -which also usually loads its own config file(s), typically from the bundle's |
53 | | -``Resources/config`` directory. Theapplevel config is usually processed with |
54 | | -a:doc:`Configuration object<components/config/definition>` also stored in the |
55 | | -bundle's ``DependencyInjection`` directory. |
| 52 | +By convention, each bundle contains an Extension class which is in the bundle's |
| 53 | +``DependencyInjection`` directory. These are registered with the ``ContainerBuilder`` |
| 54 | +when thekernel is booted. When the``ContainerBuilder`` is:doc:`compiled<components/dependency-injection/compilation>`, |
| 55 | +theapplication-levelconfiguration relevant to the bundle's extension is |
| 56 | +passed to the Extensionwhich also usually loads its own config file(s), typically from the bundle's |
| 57 | +``Resources/config`` directory. Theapplication-level config is usually processed |
| 58 | +witha:doc:`Configuration object<components/config/definition>` also stored |
| 59 | +in thebundle's ``DependencyInjection`` directory. |
56 | 60 |
|
57 | | -Compiler passes to allowinteraction betweenbundles |
| 61 | +Compiler passes to allowInteraction betweenBundles |
58 | 62 | ---------------------------------------------------- |
59 | 63 |
|
60 | 64 | :ref:`Compiler passes<components-dependency-injection-compiler-passes>` are |
61 | 65 | used to allow interaction between different bundles as they cannot affect |
62 | 66 | each others configuration in the extension classes. One of the main uses is |
63 | 67 | to process tagged services, allowing bundles to register services to picked |
64 | | -up by otherbundle, such as Monolog loggers, Twig extensions and Data Collectors |
| 68 | +up by otherbundles, such as Monolog loggers, Twig extensions and Data Collectors |
65 | 69 | for the Web Profiler. Compiler passes are usually placed in the bundle's |
66 | 70 | ``DependencyInjection/Compiler`` directory. |
67 | 71 |
|
68 | | -Compilation andcaching |
| 72 | +Compilation andCaching |
69 | 73 | ----------------------- |
70 | 74 |
|
71 | 75 | After the compilation process has loaded the services from the configuration, |
72 | | -extensions and the compiler passes it is dumped so that the cache can be used |
73 | | -next time and thedumped version then used duringthe request as it is more |
74 | | -efficient. |
| 76 | +extensions and the compiler passes, it is dumped so that the cache can be used |
| 77 | +next time. Thedumped versionisthen used duringsubsequent request as it |
| 78 | +is moreefficient. |