diff --git a/_images/components/http_kernel/01-workflow.png b/_images/components/http_kernel/01-workflow.png deleted file mode 100644 index 78c155904ca..00000000000 Binary files a/_images/components/http_kernel/01-workflow.png and /dev/null differ diff --git a/_images/components/http_kernel/02-kernel-request.png b/_images/components/http_kernel/02-kernel-request.png deleted file mode 100644 index b90aa35a3f3..00000000000 Binary files a/_images/components/http_kernel/02-kernel-request.png and /dev/null differ diff --git a/_images/components/http_kernel/03-kernel-request-response.png b/_images/components/http_kernel/03-kernel-request-response.png deleted file mode 100644 index 5f4c4a188c4..00000000000 Binary files a/_images/components/http_kernel/03-kernel-request-response.png and /dev/null differ diff --git a/_images/components/http_kernel/04-resolve-controller.png b/_images/components/http_kernel/04-resolve-controller.png deleted file mode 100644 index 6283558ebd1..00000000000 Binary files a/_images/components/http_kernel/04-resolve-controller.png and /dev/null differ diff --git a/_images/components/http_kernel/06-kernel-controller.png b/_images/components/http_kernel/06-kernel-controller.png deleted file mode 100644 index 95f1bcc4286..00000000000 Binary files a/_images/components/http_kernel/06-kernel-controller.png and /dev/null differ diff --git a/_images/components/http_kernel/07-controller-arguments.png b/_images/components/http_kernel/07-controller-arguments.png deleted file mode 100644 index 66cdaa247eb..00000000000 Binary files a/_images/components/http_kernel/07-controller-arguments.png and /dev/null differ diff --git a/_images/components/http_kernel/08-call-controller.png b/_images/components/http_kernel/08-call-controller.png deleted file mode 100644 index 877272b7c7c..00000000000 Binary files a/_images/components/http_kernel/08-call-controller.png and /dev/null differ diff --git a/_images/components/http_kernel/09-controller-returns-response.png b/_images/components/http_kernel/09-controller-returns-response.png deleted file mode 100644 index ae0d1d1d20a..00000000000 Binary files a/_images/components/http_kernel/09-controller-returns-response.png and /dev/null differ diff --git a/_images/components/http_kernel/10-kernel-view.png b/_images/components/http_kernel/10-kernel-view.png deleted file mode 100644 index cdf3329e65a..00000000000 Binary files a/_images/components/http_kernel/10-kernel-view.png and /dev/null differ diff --git a/_images/components/http_kernel/11-kernel-exception.png b/_images/components/http_kernel/11-kernel-exception.png deleted file mode 100644 index c380758e400..00000000000 Binary files a/_images/components/http_kernel/11-kernel-exception.png and /dev/null differ diff --git a/_images/components/http_kernel/http-workflow-exception.svg b/_images/components/http_kernel/http-workflow-exception.svg new file mode 100644 index 00000000000..3330010367a --- /dev/null +++ b/_images/components/http_kernel/http-workflow-exception.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/_images/components/http_kernel/http-workflow-subrequest.svg b/_images/components/http_kernel/http-workflow-subrequest.svg new file mode 100644 index 00000000000..4f4912dc5a1 --- /dev/null +++ b/_images/components/http_kernel/http-workflow-subrequest.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/_images/components/http_kernel/http-workflow.svg b/_images/components/http_kernel/http-workflow.svg new file mode 100644 index 00000000000..f3bc7a9ee8b --- /dev/null +++ b/_images/components/http_kernel/http-workflow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/_images/components/http_kernel/request-response-flow.png b/_images/components/http_kernel/request-response-flow.png deleted file mode 100644 index 2ae1011a101..00000000000 Binary files a/_images/components/http_kernel/request-response-flow.png and /dev/null differ diff --git a/_images/components/http_kernel/sub-request.png b/_images/components/http_kernel/sub-request.png deleted file mode 100644 index a26efe7ecd1..00000000000 Binary files a/_images/components/http_kernel/sub-request.png and /dev/null differ diff --git a/_images/sources/http_kernel/http-workflow.dia b/_images/sources/http_kernel/http-workflow.dia new file mode 100644 index 00000000000..2b84bc46aec Binary files /dev/null and b/_images/sources/http_kernel/http-workflow.dia differ diff --git a/components/http_kernel.rst b/components/http_kernel.rst index 5f95dd3c99a..e3e777fd6b2 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -27,9 +27,14 @@ The Workflow of a Request Every HTTP web interaction begins with a request and ends with a response. Your job as a developer is to create PHP code that reads the request information (e.g. the URL) and creates and returns a response (e.g. an HTML page or JSON string). +This is a simplified overview of the request workflow in Symfony applications: -.. image:: /_images/components/http_kernel/request-response-flow.png - :align: center +#. The **user** asks for a **resource** in a **browser**; +#. The **browser** sends a **request** to the **server**; +#. **Symfony** gives the **application** a **Request** object; +#. The **application** generates a **Response** object using the data of the **Request** object; +#. The **server** sends back the **response** to the **browser**; +#. The **browser** displays the **resource** to the **user**. Typically, some sort of framework or system is built to handle all the repetitive tasks (e.g. routing, security, etc) so that a developer can easily build @@ -62,8 +67,9 @@ the concrete implementation of :method:`HttpKernelInterface::handle() The exact details of this workflow are the key to understanding how the kernel (and the Symfony Framework or any other library that uses the kernel) works. @@ -138,9 +144,6 @@ layer that denies access). The first event that is dispatched inside :method:`HttpKernel::handle ` is ``kernel.request``, which may have a variety of different listeners. -.. image:: /_images/components/http_kernel/02-kernel-request.png - :align: center - Listeners of this event can be quite varied. Some listeners - such as a security listener - might have enough information to create a ``Response`` object immediately. For example, if a security listener determined that a user doesn't have access, @@ -150,9 +153,6 @@ to the login page or a 403 Access Denied response. If a ``Response`` is returned at this stage, the process skips directly to the :ref:`kernel.response ` event. -.. image:: /_images/components/http_kernel/03-kernel-request-response.png - :align: center - Other listeners simply initialize things or add more information to the request. For example, a listener might determine and set the locale on the ``Request`` object. @@ -205,9 +205,6 @@ to your application. This is the job of the "controller resolver" - a class that implements :class:`Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface` and is one of the constructor arguments to ``HttpKernel``. -.. image:: /_images/components/http_kernel/04-resolve-controller.png - :align: center - Your job is to create a class that implements the interface and fill in its two methods: ``getController()`` and ``getArguments()``. In fact, one default implementation already exists, which you can use directly or learn from: @@ -280,9 +277,6 @@ some part of the system that needs to be initialized after certain things have been determined (e.g. the controller, routing information) but before the controller is executed. For some examples, see the Symfony section below. -.. image:: /_images/components/http_kernel/06-kernel-controller.png - :align: center - Listeners to this event can also change the controller callable completely by calling :method:`FilterControllerEvent::setController ` on the event object that's passed to listeners on this event. @@ -314,9 +308,6 @@ should be passed to that controller. Exactly how this is done is completely up to your design, though the built-in :class:`Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver` is a good example. -.. image:: /_images/components/http_kernel/07-controller-arguments.png - :align: center - At this point the kernel has a PHP callable (the controller) and an array of arguments that should be passed when executing that callable. @@ -345,9 +336,6 @@ of arguments that should be passed when executing that callable. The next step is simple! ``HttpKernel::handle()`` executes the controller. -.. image:: /_images/components/http_kernel/08-call-controller.png - :align: center - The job of the controller is to build the response for the given resource. This could be an HTML page, a JSON string or anything else. Unlike every other part of the process so far, this step is implemented by the "end-developer", @@ -357,9 +345,6 @@ Usually, the controller will return a ``Response`` object. If this is true, then the work of the kernel is just about done! In this case, the next step is the :ref:`kernel.response ` event. -.. image:: /_images/components/http_kernel/09-controller-returns-response.png - :align: center - But if the controller returns anything besides a ``Response``, then the kernel has a little bit more work to do - :ref:`kernel.view ` (since the end goal is *always* to generate a ``Response`` object). @@ -384,9 +369,6 @@ another event - ``kernel.view``. The job of a listener to this event is to use the return value of the controller (e.g. an array of data or an object) to create a ``Response``. -.. image:: /_images/components/http_kernel/10-kernel-view.png - :align: center - This can be useful if you want to use a "view" layer: instead of returning a ``Response`` from the controller, you return data that represents the page. A listener to this event could then use this data to create a ``Response`` that @@ -515,8 +497,9 @@ function is wrapped in a try-catch block. When any exception is thrown, the ``kernel.exception`` event is dispatched so that your system can somehow respond to the exception. -.. image:: /_images/components/http_kernel/11-kernel-exception.png - :align: center +.. raw:: html + + Each listener to this event is passed a :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent` object, which you can use to access the original exception via the @@ -660,8 +643,9 @@ a page instead of a full page. You'll most commonly make sub-requests from your controller (or perhaps from inside a template, that's being rendered by your controller). -.. image:: /_images/components/http_kernel/sub-request.png - :align: center +.. raw:: html + + To execute a sub request, use ``HttpKernel::handle()``, but change the second argument as follows::