-
- Notifications
You must be signed in to change notification settings - Fork 5.3k
Comply with best practices, Round 2 #4507
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
Changes from 1 commit
3c71b6d c8ce507 de4fcf4 4ef1ef3 a29f9fb 2a97453 fdc460d 5ee9791 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -14,7 +14,7 @@ applications, while staying out of your way. Symfony is built on the best | |
| ideas from many technologies: the tools and concepts you're about to learn | ||
| represent the efforts of thousands of people, over many years. In other words, | ||
| you're not just learning "Symfony", you're learning the fundamentals of the | ||
| web, development best practices, and how to use many amazing new PHP libraries, | ||
| web, development best practices and how to use many amazing new PHP libraries, | ||
| inside or independently of Symfony. So, get ready. | ||
| | ||
| True to the Symfony philosophy, this chapter begins by explaining the fundamental | ||
| | @@ -33,9 +33,9 @@ takes place: | |
| :align: center | ||
| | ||
| And while the actual language used is a bit more formal, it's still dead-simple. | ||
| HTTP is the term used to describe this simple text-based language. And no | ||
| matter how you develop on the web, the goal of your server is *always* to | ||
| understand simple text requests, and return simple text responses. | ||
| HTTP is the term used to describe this simple text-based language. No matter | ||
| how you develop on the web, the goal of your server is *always* to understand | ||
| simple text requests, and return simple text responses. | ||
| | ||
| Symfony is built from the ground up around that reality. Whether you realize | ||
| it or not, HTTP is something you use everyday. With Symfony, you'll learn | ||
| | @@ -48,7 +48,7 @@ Step1: The Client Sends a Request | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| | ||
| Every conversation on the web starts with a *request*. The request is a text | ||
| message created by a client (e.g. a browser, an iPhone app, etc) in a | ||
| message created by a client (e.g. a browser, a smartphone app, etc) in a | ||
| special format known as HTTP. The client sends that request to a server, | ||
| and then waits for the response. | ||
| | ||
| | @@ -98,7 +98,7 @@ delete a specific blog entry, for example: | |
| | ||
| There are actually nine HTTP methods defined by the HTTP specification, | ||
| but many of them are not widely used or supported. In reality, many modern | ||
| browsers don't support the ``PUT`` and ``DELETE`` methods. | ||
| browsers don't even support the ``PUT`` and ``DELETE`` methods. | ||
| | ||
| In addition to the first line, an HTTP request invariably contains other | ||
| 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, | |
| it's inescapably simple. | ||
| | ||
| The most important fact is this: regardless of the language you use, the | ||
| type of application you build (web, mobile, JSON API), or the development | ||
| type of application you build (web, mobile, JSON API) or the development | ||
| philosophy you follow, the end goal of an application is **always** to understand | ||
| each request and create and return the appropriate response. | ||
| | ||
| | @@ -277,6 +277,7 @@ an HTTP response message. This allows your application to use an object-oriented | |
| interface to construct the response that needs to be returned to the client:: | ||
| | ||
| use Symfony\Component\HttpFoundation\Response; | ||
| | ||
| $response = new Response(); | ||
| | ||
| $response->setContent('<html><body><h1>Hello world!</h1></body></html>'); | ||
| | @@ -366,12 +367,13 @@ on that value. This can get ugly quickly:: | |
| // index.php | ||
| use Symfony\Component\HttpFoundation\Request; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
| | ||
| $request = Request::createFromGlobals(); | ||
| $path = $request->getPathInfo(); // the URI path being requested | ||
| | ||
| if (in_array($path, array('', '/'))) { | ||
| $response = new Response('Welcome to the homepage.'); | ||
| } elseif ($path == '/contact') { | ||
| } elseif ('/contact' === $path) { | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is philosophical, but I personally only use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the Symfony standard is to always use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @weaverryan the implicit type casting can create very weird bugs in your code (for instance | ||
| $response = new Response('Contact us'); | ||
| } else { | ||
| $response = new Response('Page not found.', 404); | ||
| | @@ -485,8 +487,8 @@ email messages. | |
| | ||
| .. _symfony2-build-your-app-not-your-tools: | ||
| | ||
| Symfony: Build your App, not your Tools. | ||
| ---------------------------------------- | ||
| Symfony: Build your App, not your Tools | ||
| --------------------------------------- | ||
| | ||
| You now know that the goal of any app is to interpret each incoming request | ||
| 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: | |
| about how that request should be handled (e.g. execute the ``contactAction()`` | ||
| method); | ||
| | ||
| * `Form`_ - A full-featured and flexible framework for creating forms and | ||
| handling form submissions; | ||
| * `Form </components/form/introduction>` - A full-featured and flexible | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing | ||
| framework for creating forms and handling form submissions; | ||
| | ||
| * `Validator`_ - A system for creating rules about data and then validating | ||
| whether or not user-submitted data follows those rules; | ||
| | ||
| * :doc:`ClassLoader </components/class_loader/introduction>` - An autoloading library that allows | ||
| PHP classes to be used without needing to manually ``require`` the files | ||
| containing those classes; | ||
| | ||
| * :doc:`Templating </components/templating/introduction>` - A toolkit for rendering | ||
| templates, handling template inheritance (i.e. a template is decorated with | ||
| a layout) and performing other common template tasks; | ||
| | ||
| * `Security`_ - A powerful library for handling all types of security inside | ||
| an application; | ||
| * `Security </components/security/introduction>` - A powerful library for | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing | ||
| handling all types of security inside an application; | ||
| | ||
| * `Translation`_ - A framework for translating strings in your application. | ||
| * `Translation </components/translation/introduction>` - A framework for | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing | ||
| translating strings in your application. | ||
| | ||
| Each and every one of these components is decoupled and can be used in *any* | ||
| 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. | |
| .. _`List of HTTP status codes`: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes | ||
| .. _`List of HTTP header fields`: http://en.wikipedia.org/wiki/List_of_HTTP_header_fields | ||
| .. _`List of common media types`: http://en.wikipedia.org/wiki/Internet_media_type#List_of_common_media_types | ||
| .. _`Form`: https://github.com/symfony/Form | ||
| .. _`Validator`: https://github.com/symfony/Validator | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this one link to the component doc as well ? Or is it not merged yet ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not merged yet - it's been on the lower priority because we packed so much into 2.6 and the docs needing to be re-read for updates like this :). | ||
| .. _`Security`: https://github.com/symfony/Security | ||
| .. _`Translation`: https://github.com/symfony/Translation | ||
| .. _`Swift Mailer`: http://swiftmailer.org/ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with the 📱? :P