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

Creating a new environment


Based on what we have seen so far, in order to create a new environment, all we need to do is the following:

  1. Define a new configuration file.

  2. Create a new front controller for it (in case we need to call it explicitly).

To put it in practice, let's imagine that your web application was successful enough to receive sign ups from all around the world. This means that it is wise to use regional servers for each country instead of serving everyone in the world with the same server.

One way to do this is to define different domains for different regions. Again, the code base stays the same, but configurations for the database, caching, and so on should be different. However, because we (as developers) are working from one specific address and need to find a way to Dev/Test the code from our own location, we can have a front controller for that specific region to see how it works.

Let's create the new config file and save it under the name, config_region2.yml, and create...