Skip to content

Commit 30b4830

Browse files
committed
minor #22168 [Runtime] Document Response support in FrankenPHP worker mode (lacatoire)
This PR was merged into the 8.1 branch. Discussion ---------- [Runtime] Document Response support in FrankenPHP worker mode Fixes #22164 Documents the new ability to return a `Response` object when running in FrankenPHP worker mode (Symfony 8.1). Commits ------- 2b58fa4 [Runtime] Document Response support in FrankenPHP worker mode
2 parents c505a69 + 2b58fa4 commit 30b4830

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

components/runtime.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,32 @@ The ``SymfonyRuntime`` can handle these applications:
206206
return new Response('Hello world');
207207
};
208208

209+
.. versionadded:: 8.1
210+
211+
Support for returning a ``Response`` object when running in FrankenPHP
212+
worker mode was introduced in Symfony 8.1.
213+
214+
When running in `FrankenPHP`_ worker mode, a ``Response`` object is
215+
handled by
216+
:class:`Symfony\\Component\\Runtime\\Runner\\FrankenPhpWorkerRunner`
217+
instead of the ``ResponseRunner``. This is useful for scenarios like
218+
maintenance pages where you want to return a static response while still
219+
benefiting from the worker loop::
220+
221+
// public/index.php
222+
use App\Kernel;
223+
use Symfony\Component\HttpFoundation\Response;
224+
225+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
226+
227+
return function (array $context) {
228+
if ($context['APP_MAINTENANCE'] ?? false) {
229+
return new Response('Service Unavailable', 503);
230+
}
231+
232+
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
233+
};
234+
209235
:class:`Symfony\\Component\\Console\\Command\\Command`
210236
To write single command applications. This will use the
211237
:class:`Symfony\\Component\\Runtime\\Runner\\Symfony\\ConsoleApplicationRunner`::

0 commit comments

Comments
 (0)