Take care: Work In Progress here. This article might be incomplete or contain errors. Know something we don't? Help us! Contribute here on GitHub

Install Symfony 4

Symfony has been around for some while — but it doesn't look old. Learn how to install and tune Symfony 4 on fortrabbit.

Get ready

We assume you've already created a new App and chose Symfony in the stack chooser. If not: You can do so in the fortrabbit Dashboard. You should also have a PHP development environment running on your local machine.

Root path

If you haven't chosen Symfony stack when creating the App in the Dashboard at first, please set the following: Go to the Dashboard and set the root path of your App's domains to public.

Change the root path for App URL of App: {{app-name}}

ENV vars

Symfony 4 environments are controlled by the APP_ENV ENV var. You can even use ENV vars in the .yml configurations now. To get you started quickly, we provide you with the following ENV vars by default when you have chosen the Symfony from the Software chooser when creating the App:


Within the Dashboard under your App settings you can modify the ENV vars. Modify APP_DEBUG or APP_ENV to change the behavior of your application. You can also define your own key-value-pairs and use them in your configuration files.

Go to ENV vars for the App: {{app-name}}

Quick start

We assume that you already have Symfony installed locally. If your project is not under Git version control yet, follow these steps to be prepared for your first git push.

# 1. Initialize a local Git repo
$ git init .

# 2. Add all files
$ git add -A

# 3. Commit files for the first time
$ git commit -m 'Initial'

# 4. Add fortrabbit as a remote
$ git remote add fortrabbit {{ssh-user}}@deploy.{{region}}.frbit.com:{{app-name}}.git

# 5. Initial push and set upstream
$ git push -u fortrabbit master
# Lot's of output

# 6. From there on only
$ git push

Got an error? Please see the access troubleshooting. Did it work? Cool! This first push can take a bit, since all the Composer packages need to be installed. When the first push is done you can visit your App URL in the browser and see the Symfony welcome screen:


Until now you just deployed some code. It needs some more tinkering to make it yours.


The DATABASE_URL ENV var stores all DB access information already (see above). You just need to use it in doctrine.yaml like so:

        # All in one single line (default)
        url: '%env(DATABASE_URL)%'

Doctrine & symfony console

Once doctrine is configured and the changes are deployed, you may want to create the DB schema, run migrations or load fixtures. You can login via ssh in to your App, or instead just fire single commands like so:

{{ssh-user}}@deploy.{{region}}.frbit.com 'php bin/console doctrine:schema:create'
{{ssh-user}}@deploy.{{region}}.frbit.com 'php bin/console doctrine:fixtures:load'

Webpack Encore

We assume you are using Encore to manage your css/js assets and yarn is configured in the local environment already.


In your webpack.config.js define different locations of the build - prod and dev:

var Encore = require('@symfony/webpack-encore');
var env = Encore.isProduction() ? 'prod' : 'dev';

    .setOutputPath('public/build/' + env)
    .setPublicPath('/build/' + env)
    // ...

module.exports = Encore.getWebpackConfig();

Tell the application where to find the manifest.json - again for prod and dev:

# config/package/prod/framework.yaml
        json_manifest_path: '%kernel.project_dir%/public/prod/build/manifest.json'
# config/package/dev/framework.yaml
        json_manifest_path: '%kernel.project_dir%/public/dev/build/manifest.json'

Deploying assets

Compiled assets should not be under version control. So, instead of committing the build files to Git, you deploy them separately. rsync works great for this and it's easier than you might think:

# Build production assets locally 
$ yarn run encore production

# Deploy the build/prod folder
$ rsync -av ./public/build/prod {{app-name}}@deploy.{{region}}.frbit.com:~/public/build/prod/

Advanced configurations

Still reading? Let's go on:


You can access all log files your App writes on the file system. If you want to use live logging, then you should configure Symfony to use error_log. Modify the config/packages/prod/framework.yml file:

    # ..
        # ..
            type:  error_log
            # ..

Sending mail

You can not use sendmail on fortrabbit but you can use the Swiftmailer. Configure it in your config/packages/swiftmailer.yaml file and provide the MAILER_URL ENV var in Dashboard.

    url: '%env(MAILER_URL)%'
    spool: { type: 'memory' }

Further readings

Need individual help?

Get support › Learn about Company plans ›

Looking for an old article?

See the full list of articles ›

Found an error?

Contribute on GitHub ›