Practical guide

How to start a Symfony project for a real production application

Do not start with an empty folder only. Set up healthy foundations for local development, tests, and deployment from day one.

20 minutes · Symfony

First, the short version

What does a production foundation mean?

Symfony is a framework for PHP applications. It gives you a ready-made structure, a console, configuration, and sensible defaults.

Composer keeps track of packages and their exact versions. A production foundation is not complicated: code goes to Git, secrets stay outside the repository, and each environment has its own configuration.

Get ready

What you need

You do not need a cloud account or a finished database for the first pass. A clean local environment is enough.

  • PHP in a version supported by Symfony, with the required extensions.
  • Composer installed in your terminal.
  • Git and an empty repository for the project.
  • A decision whether you are building a traditional web app or an API. Add the webapp pack for a web app; start with the skeleton alone for a small API.

Steps 1 to 3

Create the project and set up its environment

Use small, verifiable steps. After each one, you know exactly what works.

1. Create a clean Symfony project

  1. Choose a short directory name without spaces. The command creates the project, downloads dependencies, and prepares the basic structure.
  2. For a regular web application, then add webapp. It brings forms, security components, and other common foundations.
  3. Choose the framework version deliberately. For a long-lived application, the current LTS is often more useful than a random command found online.
composer create-project symfony/skeleton my-app
Official Symfony project setup guide

2. Keep settings separate from code

  1. Open .env, but do not put production secrets there. Treat it as a list of expected variables and safe default values.
  2. Use .env.local on your computer. Do not commit it. On the server, set environment variables in your host, container, or secret manager.
  3. Read database connections, API keys, and service addresses from environment variables. The same code can then run locally, in testing, and in production.
composer require webapp
Official Symfony configuration and .env documentation

3. Add the first production safeguards

  1. Commit composer.lock. It makes the server install the same tested package versions that you use locally.
  2. Make deployment run composer install without development packages, optimise the autoloader, and warm up the cache.
  3. Always turn APP_DEBUG off in production. An error page must not reveal paths, configuration, or an exception trace to visitors.
APP_ENV=prod APP_DEBUG=0 php bin/console cache:warmup
Official Composer introduction

Step 4

Check that the foundation actually holds

These three short checks catch most early mistakes.

  1. Inspect the project

    Symfony shows the version, active environment, and installed packages. Run it from the project root.

    php bin/console about
  2. Check Composer files

    Before sharing the code, check the composer.json format and consistency with the dependency lock file.

    composer validate --strict
  3. Try the production cache

    This is not a replacement for deployment, but it quickly exposes a production configuration problem or a missing variable.

    APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear

If something goes wrong

Common problems

The command reports an unsupported PHP version

Compare php -v with the requirements of the Symfony version you chose. Do not randomly change composer.json; first fix PHP locally or choose a supported framework version.

php -v
A password or API key made it into Git

Revoke the key and create a new one immediately. Deleting the line is not enough because the secret stays in history. Then move the value to an environment variable and ignore .env.local.

It works locally but not in production

Compare the list of variables, permissions for var/cache, and APP_ENV. Production must not copy a developer’s entire .env.local.

php bin/console debug:container --env-vars
Every developer has different packages

Check that composer.lock is versioned and install dependencies with composer install. Use composer update deliberately during a planned update.

git status --short

Done

The project has a foundation you can build on.

Your Symfony project now has separate configuration and its first production checks. Add features in small units and keep verifying them as you go.

Request a call

I will call you on the next working day between 9:00 and 17:00.

You can also call me directly.

+420 605 181 728

Leave your phone number and send a callback request.

By sending, you agree to processing your data in order to handle your request.