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

Installation


There are four ways to install the Symfony framework:

  • Download the archive file in the root of our project and unpack it there

  • Clone the project from GitHub

  • Use the Symfony installer tool

  • Use Composer to install it for us

The easiest way is to download the Symfony installer and make it publicly accessible via the following commands:

$ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/local/bin/symfony

Now create a new project simply by running the following command:

$ symfony new mava

As this command shows, it will ask the Symfony installer to create a new folder in the current path called mava, and when you hit enter, you will see that the Symfony source code will be downloaded to that folder:

Note

If you don't mention a version number or branch name in the installer command, it downloads and installs the latest stable version of Symfony.

In the list of things that we can do after installation is running the application immediately, without installing a virtual host. Thanks to the PHP built-in web server, we can run it via Symfony's console and browse the mava app at port 8000 on localhost:

$ bin/console server:run

The following screenshot shows how http://localhost:8000 looks like in your favourite browser:

Note

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  • Log in or register to our website using your e-mail address and password.

  • Hover the mouse pointer on the SUPPORT tab at the top.

  • Click on Code Downloads & Errata.

  • Enter the name of the book in the Search box.

  • Select the book for which you're looking to download the code files.

  • Choose from the drop-down menu where you purchased this book from.

  • Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux