Step 1: Checking your Work Environment

Checking your Work Environment

Please, don’t skip this step. Or at least, read the last section about the Symfony CLI.

You need a computer. The good news is that it can run on any popular OS: macOS, Windows, or Linux. Symfony and all the tools we are going to use are compatible with each of these.

Opinionated Choices

I want to move fast with the best options out there. I made opinionated choices for this book.

PostgreSQL is going to be our choice for everything: from database to queues, from cache to session storage. For most projects, PostgreSQL is the best solution, scale well, and allows to simplify the infrastructure with only one service to manage.

At the end of the book, we will learn how to use for queues and Redis for sessions.

IDE

You can use Notepad if you want to. I would not recommend it though.

I used to work with Textmate. Not anymore. The comfort of using a “real” IDE is priceless. Auto-completion, statements added and sorted automatically, jumping from one file to another are a few features that will boost your productivity.

I would recommend using Visual Studio Code or . The former is free, the latter is not but has a better integration with Symfony (thanks to the Symfony Support Plugin). It is up to you. I know you want to know which IDE I am using. I am writing this book in Visual Studio Code.

We will switch from the IDE to the command line all the time. You can use your IDE’s built-in terminal, but I prefer to use a real one to have more space.

Linux comes built-in with Terminal. Use on macOS. On Windows, Hyper works well.

Git

On Windows, install Git bash.

Be sure you know how to do the common operations like running git clone, git log, git show, git diff, git checkout, …

PHP

We will use Docker for services, but I like to have PHP installed on my local computer for performance, stability, and simplicity reasons. Call me old school if you like, but the combination of a local PHP and Docker services is the perfect combo for me.

Use PHP 8.0 and check that the following PHP extensions are installed or install them now: intl, pdo_pgsql, xsl, amqp, , openssl, sodium. Optionally install redis, curl, and zip as well.

You can check the extensions currently enabled via php -m.

We also need php-fpm if your platform supports it, php-cgi works as well.

Managing dependencies is everything nowadays with a Symfony project. Get the latest version of Composer, the package management tool for PHP.

If you are not familiar with Composer, take some time to read about it.

Tip

You don’t need to type the full command names: composer req does the same as composer require, use instead of composer remove, …

NodeJS

Docker and Docker Compose

Services are going to be managed by Docker and Docker Compose. and start Docker. If you are a first time user, get familiar with the tool. Don’t panic though, our usage will be very straightforward. No fancy configurations, no complex setup.

Last, but not least, we will use the symfony CLI to boost our productivity. From the local web server it provides, to full Docker integration and SymfonyCloud support, it will be a great time saver.

Install the Symfony CLI and move it under your $PATH. Create a account if you don’t have one already and log in via symfony login.

To use HTTPS locally, we also need to install a certificate authority (CA) to enable TLS support. Run the following command:

Check that your computer has all needed requirements by running the following command:

  1. $ symfony book:check-requirements

If you want to get fancy, you can also run the . It is optional but it allows you to get a local domain name ending with .wip for your project.

When executing a command in a terminal, we will almost always prefix it with symfony like in symfony composer instead of just composer, or symfony console instead of .

The main reason is that the Symfony CLI automatically sets some environment variables based on the services running on your machine via Docker. These environment variables are available for HTTP requests because the local web server injects them automatically. So, using symfony on the CLI ensures that you have the same behavior across the board.

Moreover, the Symfony CLI automatically selects the “best” possible PHP version for the project.


This work, including the code samples, is licensed under a Creative Commons BY-NC-SA 4.0 license.