Getting Started with Symfony: A Quick Beginner’s Guide

If you’ve ever heard people say “Symfony is hard”, don’t let that scare you.
Yes — it’s a powerful PHP framework used by some of the biggest platforms out there, but getting started with it isn’t rocket science.

Think of Symfony as a toolbox: once you know where each tool is kept, everything else feels natural.
In this post, we’ll go step-by-step through the basics you need to build your first Symfony app — from installing the right tools to creating your first route and page.


Step 1: Install Composer

Before Symfony, we need Composer.
Composer is like an app store for PHP — it handles all your project dependencies so you don’t have to manually hunt for libraries.

To check if you already have PHP installed, run:

php -v

If that works, great! Now install Composer:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Then confirm it’s working:

composer -V

That’s it. You can always grab the latest instructions at getcomposer.org.


Step 2: Install the Symfony CLI

Now, let’s bring in the Symfony command-line tool.
The Symfony CLI helps you create projects, run servers, manage configurations, and check if your app meets best practices.

Here’s how to install it on Linux or macOS:

curl -sS https://get.symfony.com/cli/installer | bash
mv ~/.symfony*/bin/symfony /usr/local/bin/symfony

Then check if it’s ready:

symfony -v

If it prints a version number, you’re good to go.
For other systems (e.g windows) or more detailed instructions, visit symfony.com/download.


Step 3: Create Your First Symfony Project

This is where the fun begins.
Let’s create a new Symfony project using the full web app skeleton:

# create a new project
symfony new my_project --webapp
# Enter into the project directory
cd my_project

The --webapp flag tells Symfony to include the core packages for web development — like Twig (for templates) and Doctrine (for databases).

If you’re a total beginner, don’t worry about those names yet — just know that you’ve got a fully functional modern web app structure set up in seconds.


Step 4: Understand the Directory Structure

One thing that often confuses beginners is Symfony’s folder structure.
But once you understand the purpose of each folder, it suddenly makes perfect sense.

Here’s a quick breakdown:

  • /config/ → Settings and routing configurations.
  • /src/ → Your main PHP code (controllers, classes, etc.).
  • /templates/ → HTML/Twig template files.
  • /public/ → Public-facing files (images, CSS, JS).

If you’ve ever worked with Laravel or any modern framework, you’ll notice this structure feels familiar and organized.


Step 5: Create a Route and Controller

Routes are like signs that tell Symfony “when someone visits this URL, run this code.”
And that code usually lives inside a /src/Controller/ directory.

Let’s create one:

php bin/console make:controller HomeController

This automatically creates two files for you:

  • src/Controller/HomeController.php
  • templates/home/index.html.twig

But to see how this works from scratch, here’s a super simple manually modified example:

Create a file: src/Controller/HomeController.php

<?php
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class HomeController extends AbstractController
{
    #[Route('/home', name: 'app_home')]
    public function index(): Response
    {
        return $this->render('home.html.twig', [
            'message' => 'Welcome to Symfony!'
        ]);
    }
}

Here’s what’s happening:

  • The #[Route('/home', name: 'app_home')] tells Symfony that whenever somebody visits /home on the browser, render the content of home.html.twig.
  • The controller then renders the content of the Twig template and passes a variable called message to it.

Step 6: Create a Template

Inside your templates folder, create a new file called home.html.twig:

<!DOCTYPE html>
<html>
  <head>
    <title>My First Symfony App</title>
  </head>
  <body>
    <h1>{{ message }}</h1>
  </body>
</html>

Twig uses double curly braces {{ }} to print variables.
So {{ message }} will display “Welcome to Symfony!” — or whatever message you send from your controller.


Step 7: Serve the Project

Ready to see your masterpiece?
Run this command:

symfony server:start

Then open http://localhost:8000 in your browser.

If everything worked, you’ll see your welcome message appear on screen.
That’s your first Symfony app running locally — and yes, you built it!


Wrapping Up

See? Symfony isn’t as intimidating as people make it sound.
Once you install the tools, understand the folders, and know how routes and templates connect — you’re already halfway to building something real.

From here, you can explore things like database connections (Doctrine), forms, authentication, and API endpoints. But for now, celebrate this win — because if you’ve followed along, you’ve already built a working Symfony app from scratch.

If this post helped you, consider sharing it — it really helps others discover useful resources. Thanks.