diff --git a/components/http_foundation.rst b/components/http_foundation.rst index d28a3bfa3ca..0e389abe6dd 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -288,6 +288,7 @@ represents an HTTP message. But when moving from a legacy system, adding methods or changing some default behavior might help. In that case, register a PHP callable that is able to create an instance of your ``Request`` class:: + use AppBundle\Http\SpecialRequest; use Symfony\Component\HttpFoundation\Request; Request::setFactory(function ( diff --git a/components/process.rst b/components/process.rst index 30c87c1000f..6220f662062 100644 --- a/components/process.rst +++ b/components/process.rst @@ -124,6 +124,26 @@ are done doing other stuff:: which means that your code will halt at this line until the external process is completed. +.. note:: + + If a ``Response`` is sent **before** a child process had a chance to complete, + the server process will be killed (depending on your OS). It means that + your task will be stopped right away. Running an asynchronous process + is not the same as running a process that survives its parent process. + + If you want your process to survive the request/response cycle, you can + take advantage of the ``kernel.terminate`` event, and run your command + **synchronously** inside this event. Be aware that ``kernel.terminate`` + is called only if you use PHP-FPM. + +.. caution:: + + Beware also that if you do that, the said PHP-FPM process will not be + available to serve any new request until the subprocess is finished. This + means you can quickly block your FPM pool if you're not careful enough. + That is why it's generally way better not to do any fancy things even + after the request is sent, but to use a job queue instead. + :method:`Symfony\\Component\\Process\\Process::wait` takes one optional argument: a callback that is called repeatedly whilst the process is still running, passing in the output and its type:: diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 31c8f4fbaba..deb924005a0 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -353,6 +353,11 @@ wrapping their names with ``%`` characters). sense most of the times to prevent accessing those services directly instead of using the generic service alias. +.. note:: + + You need to manually add the ``Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass`` + compiler pass to the container for this feature to work. + console.command ---------------