@@ -21,7 +21,7 @@ to render the content of a page.
2121A Simple Controller
2222-------------------
2323
24- While a controller can be any PHP callable (a function, method on an object,
24+ While a controller can be any PHP callable (function, method on an object,
2525or a ``Closure ``), a controller is usually a method inside a controller
2626class::
2727
@@ -46,7 +46,7 @@ class::
4646 }
4747 }
4848
49- The controller is the ``number() `` method, which lives inside a
49+ The controller is the ``number() `` method, which lives inside the
5050controller class ``LuckyController ``.
5151
5252This controller is pretty straightforward:
@@ -91,9 +91,9 @@ For more information on routing, see :doc:`/routing`.
9191The Base Controller Class & Services
9292------------------------------------
9393
94- To make life nicer , Symfony comes with an optional base controller class called
94+ To aid development , Symfony comes with an optional base controller class called
9595:class: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller\\ AbstractController `.
96- You can extend it to get access to some `helper methods `_.
96+ It can be extended to gain access to `helper methods `_.
9797
9898Add the ``use `` statement atop your controller class and then modify
9999``LuckyController `` to extend it:
@@ -354,8 +354,8 @@ The Request object as a Controller Argument
354354-------------------------------------------
355355
356356What if you need to read query parameters, grab a request header or get access
357- to an uploaded file? All of that information is stored in Symfony's ``Request ``
358- object. To get it in your controller, add it as an argument and
357+ to an uploaded file? That information is stored in Symfony's ``Request ``
358+ object. To access it in your controller, add it as an argument and
359359**type-hint it with the Request class **::
360360
361361 use Symfony\Component\HttpFoundation\Request;
@@ -531,13 +531,13 @@ the ``Request`` class::
531531The ``Request `` class has several public properties and methods that return any
532532information you need about the request.
533533
534- Like the ``Request ``, the ``Response `` object has also a public ``headers `` property.
535- This is a :class: `Symfony\\ Component\\ HttpFoundation\\ ResponseHeaderBag ` that has
536- some nice methods for getting and setting response headers. The header names are
537- normalized so that using ``Content-Type `` is equivalent to `` content-type `` or even
538- ``content_type ``.
534+ Like the ``Request ``, the ``Response `` object has a public ``headers `` property.
535+ This object is of the type :class: `Symfony\\ Component\\ HttpFoundation\\ ResponseHeaderBag `
536+ and provides methods for getting and setting response headers. The header names are
537+ normalized. As a result, the name ``Content-Type `` is equivalent to
538+ the name `` content-type `` or ``content_type ``.
539539
540- The only requirement for a controller is to return a ``Response `` object::
540+ In Symfony, a controller is required to return a ``Response `` object::
541541
542542 use Symfony\Component\HttpFoundation\Response;
543543
@@ -548,15 +548,15 @@ The only requirement for a controller is to return a ``Response`` object::
548548 $response = new Response('<style> ... </style>');
549549 $response->headers->set('Content-Type', 'text/css');
550550
551- There are special classes that make certain kinds of responses easier. Some of these
552- are mentioned below. To learn more about the ``Request `` and ``Response `` (and special
551+ To facilitate this, different response objects are included to address different response types.
552+ Some of these are mentioned below. To learn more about the ``Request `` and ``Response `` (and different
553553``Response `` classes), see the :ref: `HttpFoundation component documentation <component-http-foundation-request >`.
554554
555555Returning JSON Response
556556~~~~~~~~~~~~~~~~~~~~~~~
557557
558558To return JSON from a controller, use the ``json() `` helper method. This returns a
559- special ``JsonResponse `` object that encodes the data automatically::
559+ ``JsonResponse `` object that encodes the data automatically::
560560
561561 // ...
562562 public function index()
@@ -606,13 +606,15 @@ The ``file()`` helper provides some arguments to configure its behavior::
606606Final Thoughts
607607--------------
608608
609- Whenever you create a page, you'll ultimately need to write some code that
610- contains the logic for that page. In Symfony, this is called a controller,
611- and it's a PHP function where you can do anything in order to return the
612- final ``Response `` object that will be returned to the user.
609+ In Symfony, a controller is usually a class method which is used to accept requests,
610+ and return a ``Response `` object. When mapped with a url, a controller becomes accessible
611+ and its response can be viewed.
613612
614- To make life easier, you'll probably extend the base ``AbstractController `` class because
615- this gives access to shortcut methods (like ``render() `` and ``redirectToRoute() ``).
613+ To facilitate the development of controllers, Symfony provides an ``AbstractController ``. It
614+ can be used to extend the controller class allowing access to some frequently used utilities
615+ such as ``render `` and ``redirectToRoute ``. The ``AbstractController `` also
616+ provides the ``createNotFoundException `` utility which is used to return a page
617+ not found response.
616618
617619In other articles, you'll learn how to use specific services from inside your controller
618620that will help you persist and fetch objects from a database, process form submissions,
0 commit comments