Book Image

Mastering Symfony

Book Image

Mastering Symfony

Overview of this book

In this book, you will learn some lesser known aspects of development with Symfony, and you will see how to use Symfony as a framework to create reliable and effective applications. You might have developed some impressive PHP libraries in other projects, but what is the point when your library is tied to one particular project? With Symfony, you can turn your code into a service and reuse it in other projects. This book starts with Symfony concepts such as bundles, routing, twig, doctrine, and more, taking you through the request/response life cycle. You will then proceed to set up development, test, and deployment environments in AWS. Then you will create reliable projects using Behat and Mink, and design business logic, cover authentication, and authorization steps in a security checking process. You will be walked through concepts such as DependencyInjection, service containers, and services, and go through steps to create customized commands for Symfony's console. Finally, the book covers performance optimization and the use of Varnish and Memcached in our project, and you are treated with the creation of database agnostic bundles and best practices.
Table of Contents (17 chapters)
Mastering Symfony
Credits
About the Author
About the Reviewers
Index

The big picture


The request/response life cycle can be summarized in these two simple steps:

  1. Firstly, you send your request by entering a URL in your browser.

  2. The server then responds with a page and message (success, failure, and so on) depending on your request. End of story.

The following image shows an example of the request/response life cycle:

A web server receives a request and passes it to an action unit for further processing. In our case, this action unit is somewhere in Symfony and is in charge of receiving requests. Depending on their type, it will fetch a resource (such as a record from the database or an image from the server's hard drive) or do something (like sending an e-mail or assembling and returning a JavaScript Object Notation (JSON) string). Finally, it renders a page based on the results and sends it back to the browser. After the job is done, this action unit marks the request and response as terminated and looks for the next request, as shown in the following diagram...