Hey there! I'm excited to begin the installation process for Symfony as we embark on our journey of building a custom Blog from scratch. The goal is to create a solid foundation that can be used as a starting point for any future projects. Follow along as we walk through each step and get Symfony up and running on our local machine. Let's dive in!
To install and use Symfony, you will need to have PHP and Composer installed on your local machine. Please ensure that you have these requirements met before proceeding with the installation process.
Part 1: Installing the Symfony CLI
After ensuring that you have PHP and Composer installed, the next step is to install the Symfony CLI. Here's how to get started:
- Open your terminal (command prompt on Windows).
- Retrieve the installation command for Symfony CLI using curl
- If you don't have curl installed, you can also download the installer manually from the Symfony website.
- Follow the instructions provided by the installer to complete the installation process.
$ curl -sS https://get.symfony.com/cli/installer | bash
Once the Symfony CLI is installed, you'll have access to a variety of useful commands that will help you create and manage Symfony projects. Let's move on to the next step!

Part 2: Installing the project
With the Symfony CLI installed, we're ready to create our new project.
- Open your terminal and navigate to the directory where you want to create your project.
- Enter the following command, replacing
{project_name}
with the name you want to give your project and{version_number}
with the version of Symfony you want to use. This will create a new Symfony project with the specified name and version, along with a basic web application skeleton.
$ symfony new {project_name} --version="{version_number}" --webapp
- Wait for the installation process to complete. This may take a few minutes, depending on your internet connection and the complexity of the project.
- Once the installation is complete, you can open the project directory in your favorite IDE and start working on your application. Here's what the basic project architecture should look like:

Part 3: Configuration
Configuring Symfony begins with the .env files. These files allow you to define sensitive variables like your database connection details. It's recommended to use environment variables in production instead of .env files. In the .env file (by default), there are four variables to pay attention to: APP_ENV, APP_SECRET, DATABASE_URL, and MESSENGER_TRANSPORT_DSN. These variables define the environment, security measures, database connection, and messaging system of your Symfony project. Let's dive deeper into each of them.
The first variable you'll see in the .env file is APP_ENV
. It allows you to define the environment and, if you're not in production, to display trace/debug information in case of errors.
The APP_SECRET
variable is a string used by Symfony to enhance the security of your application. It's recommended to change it frequently, and never to share it publicly.
The next variable in the .env file is DATABASE_URL
. This variable allows you to define the connection with your database. Symfony supports various types of databases, including SQL and NoSQL. For this case study, we will use SQLite. However, it is recommended to use MySQL or PostgreSQL for production environments.
MESSENGER_TRANSPORT_DSN
allows you to configure the Symfony Messenger component, which enables asynchronous processing and queueing in Symfony. By default, it uses Doctrine as its transport, which stores the queue directly in the database. However, if you need to process many asynchronous tasks, it's recommended to use a more efficient transport like Redis or RabbitMQ. AWS users can utilize AWS SQS.
APP_ENV=dev
APP_SECRET=4de3cfc67655b6cc7179d284824a66e5
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
Part 4: Testing the Application
After configuring Symfony, you can test your application by going to the base directory and typing "symfony serve" in the terminal. By default, the server will listen to 127.0.0.1:8000, and you can retrieve the URL in the terminal. Keep the command launched during development. Then, you can open the link http://127.0.0.1:8000 on your browser to see your Symfony application in action.

In this article, we went through the steps to install Symfony for our case study, from installing Symfony CLI to configuring the .env file and testing the application. Stay tuned for the next article where we will configure authentication to secure our application. As a reminder, exclusive content will be available for subscribers.