Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Foundation edits #123

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 14 additions & 13 deletions book/http_fundamentals.rst
Expand Up @@ -145,7 +145,7 @@ Symfony is architected to match this reality.
Requests and Responses in Symfony
---------------------------------

PHP comes packaged with an array variables and methods that allow the developer
PHP comes packaged with array variables and methods that allow the developer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've kept this one with the old syntax - there should be an indefinite article here.

to understand each request and send a response. For request information,
PHP prepares superglobal variables such as ``$_SERVER`` and ``$_GET``.
Recall that each raw request is simply an HTTP-formatted block of text.
Expand Down Expand Up @@ -193,7 +193,7 @@ to the client::
use Symfony\Component\HttpFoundation\Response;
$response = new Response();

$response->setContent('<html><body><h1>Hello world!</h1></body></html');
$response->setContent('<html><body><h1>Hello world!</h1></body></html>');
$response->setStatusCode(200);
$response->headers->set('Content-Type', 'text/html');

Expand Down Expand Up @@ -221,8 +221,8 @@ The Journey from the Request to the Response
We know now that the end goal of any application is to use the HTTP
request to create and return the appropriate HTTP response. Symfony provides
``Request`` and ``Response`` classes that allow this to be done through
an object-oriented interface. Though, so far, we're only leveraging a small
piece of Symfony, we already have the tools to write a simple application!
an object-oriented interface. So far, we're only leveraging a small
piece of Symfony. But we already have the tools to write a simple application!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've taken this in, but I actually liked it better how it was before. Did it not read well before? The two new sentences are now a bit more disconnected, whereas the idea is to say that we haven't see much Symfony yet, but we already know enough to be dangerous. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for response delay, was on vacation when submitting this pull request.

I see on problem if you wanted to rejoin the sentences with a comma: "...a small piece of Symfony, but we already..." Having "Though, so far, we're only..." seemed too choppy for my taste.

Recall that a large part of the Symfony community's first language is not English, so the more straightforward and simple our writing, the easier it is to understand and translate.

Let's dive in:

.. code-block:: php
Expand All @@ -241,14 +241,14 @@ Let's dive in:
$response->send();

In this simple example, the application correctly processes the request and
returns an appropriate response. From a very technical standpoint, then, our
returns an appropriate response. From a very technical standpoint, our
application does exactly what it should.

An Application without a Framework
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

But what if the application needs to grow? Imagine this same application if it
were forced now to handle hundreds or even thousands of different pages! In
were now forced to handle hundreds or even thousands of different pages! In
order to keep things maintainable (i.e. not all in one file), we'd need to do
some reorganization. For starters, we might move the work of creating the
``Response`` into a set of different functions. These functions are commonly
Expand Down Expand Up @@ -280,7 +280,8 @@ known as *controllers* and allow us to further organize our code::
Next, our growing application still contains a long ``if`` ``elseif`` block
that routes the creation of the ``Response`` object to a different controller
(i.e. PHP method). We might consider building a configuration-based routing
system that maps each request (by URI and HTTP method) to a specific controller.
system that maps each request to a specific controller based on the URI and
HTTP method of the request.

Obvious or not, the application is beginning to spin out of control. Recall
that the goal of any application is to apply the custom application logic and
Expand Down Expand Up @@ -309,15 +310,15 @@ for use.
Introducing the Symfony Kernel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Symfony is based around a ``Kernel`` object whose only job is to facilitate
Symfony is based around a ``Kernel`` object whose single responsibility is to facilitate
the journey from the ``Request`` object to the final ``Response`` object.
The ``Kernel`` is what handles each request and actually executes your application
code.

The "application code" that's executed by the ``Kernel`` is called a "controller",
The "application code" executed by the ``Kernel`` is called a "controller",
a special term for what's actually a basic PHP callable (most commonly,
an object method). The controller is where your application code lives -
it's where you create the final ``Response`` object. The Kernel works by
it's where you create the final ``Response`` object. The ``Kernel`` works by
determining and then calling a "Controller" for each request:

.. code-block:: text
Expand All @@ -338,7 +339,7 @@ elsewhere and handled by the ``Kernel``::

public function aboutAction()
{
return Response('About us');
return new Response('About us');
}
}

Expand Down Expand Up @@ -384,7 +385,7 @@ In reality, everything we've talked about so far (the ``Request``, ``Response``,
used by Symfony. In fact, each feature in Symfony2 belongs to one of over
twenty independent libraries (called the "Symfony Components")! Even if you
decided to build your own PHP framework (an unwise idea), you could use the
Symfony2 Components as the building blocks for many layers of functionality.
Symfony Components as the building blocks for many layers of functionality.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - this makes it consistent with the rest of the chapter. I need to get a final word on this, but we may change everything to ultimately say "Symfony2", which is what's most commonly used throughout the docs.

And if you do use Symfony2, but need to replace a component entirely, you have
the ability to do that. Symfony2 is decoupled and relies on interface-driven
dependency injection. In other words, the developer has complete control.
Expand All @@ -395,7 +396,7 @@ a PHP framework that accomplishes two distinct tasks:
#. Provides a selection of components (i.e. the Symfony2 Components) and
third-party libraries.

#. Provides sensible configuration that ties everything together nicely.
#. Provides sensible configuration that nicely ties everything together.

The goal of the framework is to integrate many independent tools in order
to provide a consistent experience for the developer. Even the framework
Expand Down