@@ -14,7 +14,7 @@ applications, while staying out of your way. Symfony is built on the best
14
14
ideas from many technologies: the tools and concepts you're about to learn
15
15
represent the efforts of thousands of people, over many years. In other words,
16
16
you're not just learning "Symfony", you're learning the fundamentals of the
17
- web, development best practices, and how to use many amazing new PHP libraries,
17
+ web, development best practices and how to use many amazing new PHP libraries,
18
18
inside or independently of Symfony. So, get ready.
19
19
20
20
True to the Symfony philosophy, this chapter begins by explaining the fundamental
@@ -33,9 +33,9 @@ takes place:
33
33
:align: center
34
34
35
35
And while the actual language used is a bit more formal, it's still dead-simple.
36
- HTTP is the term used to describe this simple text-based language. And no
37
- matter how you develop on the web, the goal of your server is *always * to
38
- understand simple text requests, and return simple text responses.
36
+ HTTP is the term used to describe this simple text-based language. No matter
37
+ how you develop on the web, the goal of your server is *always * to understand
38
+ simple text requests, and return simple text responses.
39
39
40
40
Symfony is built from the ground up around that reality. Whether you realize
41
41
it or not, HTTP is something you use everyday. With Symfony, you'll learn
@@ -48,7 +48,7 @@ Step1: The Client Sends a Request
48
48
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49
49
50
50
Every conversation on the web starts with a *request *. The request is a text
51
- message created by a client (e.g. a browser, an iPhone app, etc) in a
51
+ message created by a client (e.g. a browser, a smartphone app, etc) in a
52
52
special format known as HTTP. The client sends that request to a server,
53
53
and then waits for the response.
54
54
@@ -98,7 +98,7 @@ delete a specific blog entry, for example:
98
98
99
99
There are actually nine HTTP methods defined by the HTTP specification,
100
100
but many of them are not widely used or supported. In reality, many modern
101
- browsers don't support the ``PUT `` and ``DELETE `` methods.
101
+ browsers don't even support the ``PUT `` and ``DELETE `` methods.
102
102
103
103
In addition to the first line, an HTTP request invariably contains other
104
104
lines of information called request headers. The headers can supply a wide
@@ -161,7 +161,7 @@ communication on the web. And as important and powerful as this process is,
161
161
it's inescapably simple.
162
162
163
163
The most important fact is this: regardless of the language you use, the
164
- type of application you build (web, mobile, JSON API), or the development
164
+ type of application you build (web, mobile, JSON API) or the development
165
165
philosophy you follow, the end goal of an application is **always ** to understand
166
166
each request and create and return the appropriate response.
167
167
@@ -277,6 +277,7 @@ an HTTP response message. This allows your application to use an object-oriented
277
277
interface to construct the response that needs to be returned to the client::
278
278
279
279
use Symfony\Component\HttpFoundation\Response;
280
+
280
281
$response = new Response();
281
282
282
283
$response->setContent('<html><body><h1>Hello world!</h1></body></html>');
@@ -366,12 +367,13 @@ on that value. This can get ugly quickly::
366
367
// index.php
367
368
use Symfony\Component\HttpFoundation\Request;
368
369
use Symfony\Component\HttpFoundation\Response;
370
+
369
371
$request = Request::createFromGlobals();
370
372
$path = $request->getPathInfo(); // the URI path being requested
371
373
372
374
if (in_array($path, array('', '/'))) {
373
375
$response = new Response('Welcome to the homepage.');
374
- } elseif ($path == '/contact') {
376
+ } elseif ('/contact' === $path ) {
375
377
$response = new Response('Contact us');
376
378
} else {
377
379
$response = new Response('Page not found.', 404);
@@ -485,8 +487,8 @@ email messages.
485
487
486
488
.. _symfony2-build-your-app-not-your-tools :
487
489
488
- Symfony: Build your App, not your Tools.
489
- ----------------------------------------
490
+ Symfony: Build your App, not your Tools
491
+ ---------------------------------------
490
492
491
493
You now know that the goal of any app is to interpret each incoming request
492
494
and create an appropriate response. As an application grows, it becomes more
@@ -522,24 +524,21 @@ regardless of how your project is developed. To name a few:
522
524
about how that request should be handled (e.g. execute the ``contactAction() ``
523
525
method);
524
526
525
- * `Form `_ - A full-featured and flexible framework for creating forms and
526
- handling form submissions;
527
+ * `Form </components/form/introduction> ` - A full-featured and flexible
528
+ framework for creating forms and handling form submissions;
527
529
528
530
* `Validator `_ - A system for creating rules about data and then validating
529
531
whether or not user-submitted data follows those rules;
530
532
531
- * :doc: `ClassLoader </components/class_loader/introduction >` - An autoloading library that allows
532
- PHP classes to be used without needing to manually ``require `` the files
533
- containing those classes;
534
-
535
533
* :doc: `Templating </components/templating/introduction >` - A toolkit for rendering
536
534
templates, handling template inheritance (i.e. a template is decorated with
537
535
a layout) and performing other common template tasks;
538
536
539
- * `Security `_ - A powerful library for handling all types of security inside
540
- an application;
537
+ * `Security </components/security/introduction> ` - A powerful library for
538
+ handling all types of security inside an application;
541
539
542
- * `Translation `_ - A framework for translating strings in your application.
540
+ * `Translation </components/translation/introduction> ` - A framework for
541
+ translating strings in your application.
543
542
544
543
Each and every one of these components is decoupled and can be used in *any *
545
544
PHP project, regardless of whether or not you use the Symfony framework.
@@ -576,8 +575,5 @@ sensible defaults. For more advanced users, the sky is the limit.
576
575
.. _`List of HTTP status codes` : http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
577
576
.. _`List of HTTP header fields` : http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
578
577
.. _`List of common media types` : http://en.wikipedia.org/wiki/Internet_media_type#List_of_common_media_types
579
- .. _`Form` : https://github.com/symfony/Form
580
578
.. _`Validator` : https://github.com/symfony/Validator
581
- .. _`Security` : https://github.com/symfony/Security
582
- .. _`Translation` : https://github.com/symfony/Translation
583
579
.. _`Swift Mailer` : http://swiftmailer.org/
0 commit comments