How to Create a New Symfony Application

How to Create a New Symfony Application

When starting a new Symfony project, you can set it up in two ways:

  1. Using the Symfony CLI (recommended for most developers)
  2. Using Composer directly

Both methods will create the same result: a brand-new Symfony 7.3 application, ready to use. Let’s go through both approaches step by step.


Installing Symfony CLI

The Symfony CLI is an official developer tool that helps you build, run, and manage Symfony applications. It works on macOS, Windows, and Linux, and once installed, you can use it for all your projects.

Step 1: Download the Symfony CLI

Depending on your operating system, you can install it as follows:

On macOS (using Homebrew)

brew install symfony-cli/tap/symfony-cli

On Linux (using cURL)

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

On Windows

Download the installer from the official Symfony website:
https://symfony.com/download


Step 2: Verify the Installation

Run the following command to make sure Symfony is installed correctly:

symfony -v

This should display the installed Symfony CLI version.


Step 3: Create a New Symfony Project

Now you can create a Symfony 7.3 application using:

symfony new my_project --webapp

This command will:

  • Create a new folder called my_project/
  • Install Symfony 7.3 with all the necessary dependencies
  • Include the WebApp pack by default (Twig, Doctrine, UX, etc.)

After installation, move into your project directory:

cd my_project

Then start the local web server:

symfony serve

Now, open http://localhost:8000 in your browser—you’ll see your brand-new Symfony app running! 🚀


Creating a Symfony Project with Composer

If you prefer not to use the Symfony CLI, you can still set up your project using Composer.

Step 1: Create the Project Skeleton

composer create-project symfony/skeleton:"7.3.x" my_project_directory

This generates a minimal Symfony project with only the essentials.

Step 2: Navigate into Your Project

cd my_project_directory

Step 3: Install the WebApp Pack

composer require webapp

This installs common Symfony bundles (Twig, Doctrine, etc.) so you’re ready to build a full application.


What’s the Difference?

  • Symfony CLI is faster and includes everything you need out of the box, including a built-in local web server.
  • Composer gives you a more manual approach where you start with a minimal skeleton and add features as needed.

Both methods result in a fully functional Symfony 7.3 application—you just pick the workflow you prefer.


Final Thoughts

If you’re new to Symfony, I recommend starting with the Symfony CLI because it simplifies setup and includes handy tools for local development. However, if you prefer complete control or already use Composer extensively, the Composer method works just as well.

Either way, once your project is created, you’re ready to start defining routes, creating controllers, and building your Symfony application.