@@ -141,36 +141,14 @@ either the ``app.php`` (for the ``prod`` environment) or the ``app_dev.php``
141
141
:doc: `Installing Symfony2 </book/installation >`.
142
142
143
143
If you open up one of these files, you'll quickly see that the environment
144
- used by each is explicitly set:
144
+ used by each is explicitly set::
145
145
146
- .. code-block :: php
147
- :linenos:
148
-
149
- <?php
150
-
151
- use Symfony\Component\ClassLoader\ApcClassLoader;
152
- use Symfony\Component\HttpFoundation\Request;
153
-
154
- $loader = require_once __DIR__.'/../app/bootstrap.php.cache';
155
-
156
- // Use APC for autoloading to improve performance.
157
- // Change 'sf2' to a unique prefix in order to prevent cache key conflicts
158
- // with other applications also using APC.
159
- /*
160
- $loader = new ApcClassLoader('sf2', $loader);
161
- $loader->register(true);
162
- */
163
-
164
- require_once __DIR__.'/../app/AppKernel.php';
165
- //require_once __DIR__.'/../app/AppCache.php';
146
+ // web/app.php
147
+ // ...
166
148
167
149
$kernel = new AppKernel('prod', false);
168
- $kernel->loadClassCache();
169
- //$kernel = new AppCache($kernel);
170
- $request = Request::createFromGlobals();
171
- $response = $kernel->handle($request);
172
- $response->send();
173
- $kernel->terminate($request, $response);
150
+
151
+ // ...
174
152
175
153
As you can see, the ``prod `` key specifies that this environment will run
176
154
in the ``prod `` environment. A Symfony2 application can be executed in any
@@ -189,14 +167,14 @@ environment by using this code and changing the environment string.
189
167
.. sidebar :: *Debug* Mode
190
168
191
169
Important, but unrelated to the topic of *environments * is the ``false ``
192
- key on line 8 of the front controller above . This specifies whether or
193
- not the application should run in "debug mode". Regardless of the environment,
194
- a Symfony2 application can be run with debug mode set to `` true `` or
195
- `` false ``. This affects many things in the application, such as whether
196
- or not errors should be displayed or if cache files are dynamically rebuilt
197
- on each request. Though not a requirement, debug mode is generally set
198
- to ``true `` for the ``dev `` and ``test `` environments and `` false `` for
199
- the ``prod `` environment.
170
+ argument as the second argument to the `` AppKernel `` constructor . This
171
+ specifies whether or not the application should run in "debug mode". Regardless
172
+ of the environment, a Symfony2 application can be run with debug mode
173
+ set to `` true `` or `` false ``. This affects many things in the application,
174
+ such as whether or not errors should be displayed or if cache files are
175
+ dynamically rebuilt on each request. Though not a requirement, debug mode
176
+ is generally set to ``true `` for the ``dev `` and ``test `` environments
177
+ and `` false `` for the ``prod `` environment.
200
178
201
179
Internally, the value of the debug mode becomes the ``kernel.debug ``
202
180
parameter used inside the :doc: `service container </book/service_container >`.
@@ -287,35 +265,15 @@ the ``prod`` environment, except for any changes explicitly made here.
287
265
288
266
Because you'll want this environment to be accessible via a browser, you
289
267
should also create a front controller for it. Copy the ``web/app.php `` file
290
- to ``web/app_benchmark.php `` and edit the environment to be ``benchmark ``:
268
+ to ``web/app_benchmark.php `` and edit the environment to be ``benchmark ``::
291
269
292
- .. code-block :: php
293
-
294
- <?php
295
-
296
- use Symfony\Component\ClassLoader\ApcClassLoader;
297
- use Symfony\Component\HttpFoundation\Request;
298
-
299
- $loader = require_once __DIR__.'/../app/bootstrap.php.cache';
270
+ // web/app_benchmark.php
300
271
301
- // Use APC for autoloading to improve performance.
302
- // Change 'sf2' to a unique prefix in order to prevent cache key conflicts
303
- // with other applications also using APC.
304
- /*
305
- $loader = new ApcClassLoader('sf2', $loader);
306
- $loader->register(true);
307
- */
308
-
309
- require_once __DIR__.'/../app/AppKernel.php';
310
- //require_once __DIR__.'/../app/AppCache.php';
311
272
273
+ // change just this line
312
274
$kernel = new AppKernel('benchmark', false);
313
- $kernel->loadClassCache();
314
- //$kernel = new AppCache($kernel);
315
- $request = Request::createFromGlobals();
316
- $response = $kernel->handle($request);
317
- $response->send();
318
- $kernel->terminate($request, $response);
275
+
276
+ // ...
319
277
320
278
The new environment is now accessible via::
321
279
0 commit comments