Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21dc1f0

Browse files
committed
[symfony#3245] Removing most of the front controller code altogether
This removes code that could easily become out of date again. Also, I don't thinkit was necessary - we want to focus them on only one line anyways.
1 parent22e7767 commit21dc1f0

File tree

1 file changed

+18
-60
lines changed

1 file changed

+18
-60
lines changed

‎cookbook/configuration/environments.rst

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -141,36 +141,14 @@ either the ``app.php`` (for the ``prod`` environment) or the ``app_dev.php``
141141
:doc:`Installing Symfony2</book/installation>`.
142142

143143
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::
145145

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+
// ...
166148

167149
$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+
// ...
174152

175153
As you can see, the ``prod`` key specifies that this environment will run
176154
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.
189167
..sidebar::*Debug* Mode
190168

191169
Important, but unrelated to the topic of *environments* is the ``false``
192-
key on line 8 ofthefront 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 tothe``AppKernel`` constructor. This
171+
specifies whether ornot 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 whetheror not errors should be displayed or if cache files are
175+
dynamically rebuilton each request. Though not a requirement, debug mode
176+
is generally setto ``true`` for the ``dev`` and ``test`` environments
177+
and ``false`` forthe ``prod`` environment.
200178

201179
Internally, the value of the debug mode becomes the ``kernel.debug``
202180
parameter used inside the:doc:`service container</book/service_container>`.
@@ -287,35 +265,15 @@ the ``prod`` environment, except for any changes explicitly made here.
287265

288266
Because you'll want this environment to be accessible via a browser, you
289267
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``::
291269

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
300271

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';
311272

273+
// change just this line
312274
$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+
// ...
319277

320278
The new environment is now accessible via::
321279

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp