Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • SensioLabs Professional services to help you with Symfony
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by SensioLabs
  1. Home
  2. Documentation
  3. How to Deploy a Symfony Application
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud

Table of Contents

  • Symfony Deployment Basics
  • How to Deploy a Symfony Application
    • Basic File Transfer
    • Using Source Control
    • Using Platforms as a Service
    • Using Build Scripts and other Tools
  • Common Post-Deployment Tasks
    • A) Check Requirements
    • B) Configure your app/config/parameters.yml File
    • C) Install/Update your Vendors
    • D) Clear your Symfony Cache
    • E) Dump your Assetic Assets
    • F) Other Things!
  • Application Lifecycle: Continuous Integration, QA, etc

How to Deploy a Symfony Application

Edit this page

Warning: You are browsing the documentation for Symfony 3.1, which is no longer maintained.

Read the updated version of this page for Symfony 6.2 (the current stable version).

How to Deploy a Symfony Application

Deploying a Symfony application can be a complex and varied task depending on the setup and the requirements of your application. This article is not a step- by-step guide, but is a general list of the most common requirements and ideas for deployment.

Symfony Deployment Basics

The typical steps taken while deploying a Symfony application include:

  1. Upload your code to the production server;
  2. Install your vendor dependencies (typically done via Composer and may be done before uploading);
  3. Running database migrations or similar tasks to update any changed data structures;
  4. Clearing (and optionally, warming up) your cache.

A deployment may also include other tasks, such as:

  • Tagging a particular version of your code as a release in your source control repository;
  • Creating a temporary staging area to build your updated setup "offline";
  • Running any tests available to ensure code and/or server stability;
  • Removal of any unnecessary files from the web/ directory to keep your production environment clean;
  • Clearing of external cache systems (like Memcached or Redis).

How to Deploy a Symfony Application

There are several ways you can deploy a Symfony application. Start with a few basic deployment strategies and build up from there.

Basic File Transfer

The most basic way of deploying an application is copying the files manually via FTP/SCP (or similar method). This has its disadvantages as you lack control over the system as the upgrade progresses. This method also requires you to take some manual steps after transferring the files (see Common Post-Deployment Tasks)

Using Source Control

If you're using source control (e.g. Git or SVN), you can simplify by having your live installation also be a copy of your repository. When you're ready to upgrade it is as simple as fetching the latest updates from your source control system.

This makes updating your files easier, but you still need to worry about manually taking other steps (see Common Post-Deployment Tasks).

Using Platforms as a Service

The specific deployment steps vary greatly from one service provider to another, so check out the dedicated article for the service of your choose:

  • Deploying to Microsoft Azure Website Cloud
  • Deploying to fortrabbit
  • Deploying to Heroku Cloud
  • Deploying to Platform.sh

Using Build Scripts and other Tools

There are also tools to help ease the pain of deployment. Some of them have been specifically tailored to the requirements of Symfony.

Capistrano with Symfony plugin
Capistrano is a remote server automation and deployment tool written in Ruby. Symfony plugin is a plugin to ease Symfony related tasks, inspired by Capifony (which works only with Capistrano 2 )
sf2debpkg
Helps you build a native Debian package for your Symfony project.
Magallanes
This Capistrano-like deployment tool is built in PHP, and may be easier for PHP developers to extend for their needs.
Fabric
This Python-based library provides a basic suite of operations for executing local or remote shell commands and uploading/downloading files.
Deployer
This is another native PHP rewrite of Capistrano, with some ready recipes for Symfony.
Bundles
There are some bundles that add deployment features directly into your Symfony console.
Basic scripting
You can of course use shell, Ant or any other build tool to script the deploying of your project.

Common Post-Deployment Tasks

After deploying your actual source code, there are a number of common things you'll need to do:

A) Check Requirements

Check if your server meets the requirements by running:

1
$ php bin/symfony_requirements

B) Configure your app/config/parameters.yml File

This file should not be deployed, but managed through the automatic utilities provided by Symfony.

C) Install/Update your Vendors

Your vendors can be updated before transferring your source code (i.e. update the vendor/ directory, then transfer that with your source code) or afterwards on the server. Either way, just update your vendors as you normally do:

1
$ composer install --no-dev --optimize-autoloader

Tip

The --optimize-autoloader flag improves Composer's autoloader performance significantly by building a "class map". The --no-dev flag ensures that development packages are not installed in the production environment.

Caution

If you get a "class not found" error during this step, you may need to run export SYMFONY_ENV=prod before running this command so that the post-install-cmd scripts run in the prod environment.

D) Clear your Symfony Cache

Make sure you clear (and warm-up) your Symfony cache:

1
$ php bin/console cache:clear --env=prod --no-debug

E) Dump your Assetic Assets

If you're using Assetic, you'll also want to dump your assets:

1
$ php bin/console assetic:dump --env=prod --no-debug

F) Other Things!

There may be lots of other things that you need to do, depending on your setup:

  • Running any database migrations
  • Clearing your APC cache
  • Running assets:install (already taken care of in composer install)
  • Add/edit CRON jobs
  • Pushing assets to a CDN

Application Lifecycle: Continuous Integration, QA, etc

While this entry covers the technical details of deploying, the full lifecycle of taking code from development up to production may have a lot more steps (think deploying to staging, QA (Quality Assurance), running tests, etc).

The use of staging, testing, QA, continuous integration, database migrations and the capability to roll back in case of failure are all strongly advised. There are simple and more complex tools and one can make the deployment as easy (or sophisticated) as your environment requires.

Don't forget that deploying your application also involves updating any dependency (typically via Composer), migrating your database, clearing your cache and other potential things like pushing assets to a CDN (see Common Post-Deployment Tasks).

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    We stand with Ukraine.
    Version:
    Measure & Improve Symfony Code Performance

    Measure & Improve Symfony Code Performance

    Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

    Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

    Symfony footer

    ↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

    Avatar of mark burdett, a Symfony contributor

    Thanks mark burdett for being a Symfony contributor

    1 commit • 108 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • Symfony at a Glance
      • Symfony Components
      • Case Studies
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • SymfonyConnect
      • Support
      • How to be Involved
      • Code of Conduct
      • Events & Meetups
      • Projects using Symfony
      • Downloads Stats
      • Contributors
      • Backers
    • Blog

      • Events & Meetups
      • A week of symfony
      • Case studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Documentation
      • Living on the edge
      • Releases
      • Security Advisories
      • SymfonyInsight
      • Twig
      • SensioLabs
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Deployed on

    Follow Symfony

    Search by Algolia