Skip to content

Commit 22e7767

Browse files
committed
Merge pull request symfony#3245 from bicpi/fix_front_controller_code
[Cookbook][Configuration] Fix front controller sample codes
2 parents 66ee944 + eca38a2 commit 22e7767

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

Diff for: cookbook/configuration/environments.rst

+41-9
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,29 @@ used by each is explicitly set:
148148
149149
<?php
150150
151-
require_once __DIR__.'/../app/bootstrap_cache.php';
152-
require_once __DIR__.'/../app/AppCache.php';
153-
151+
use Symfony\Component\ClassLoader\ApcClassLoader;
154152
use Symfony\Component\HttpFoundation\Request;
155153
156-
$kernel = new AppCache(new AppKernel('prod', false));
157-
$kernel->handle(Request::createFromGlobals())->send();
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';
166+
167+
$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);
158174
159175
As you can see, the ``prod`` key specifies that this environment will run
160176
in the ``prod`` environment. A Symfony2 application can be executed in any
@@ -277,13 +293,29 @@ to ``web/app_benchmark.php`` and edit the environment to be ``benchmark``:
277293
278294
<?php
279295
280-
require_once __DIR__.'/../app/bootstrap.php';
281-
require_once __DIR__.'/../app/AppKernel.php';
282-
296+
use Symfony\Component\ClassLoader\ApcClassLoader;
283297
use Symfony\Component\HttpFoundation\Request;
284298
299+
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
300+
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+
285312
$kernel = new AppKernel('benchmark', false);
286-
$kernel->handle(Request::createFromGlobals())->send();
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);
287319
288320
The new environment is now accessible via::
289321

0 commit comments

Comments
 (0)