Bridge library for running Symfony Flex on

2.5.0 2021-01-08 16:19 UTC

This package is auto-updated.

Last update: 2021-01-08 17:46:16 UTC


This simple bridge library connects a Symfony Flex-based application to In the typical case it should be completely fire-and-forget.

Symfony Flex expects all configuration to come in through environment variables with specific names in a specific format. provides configuration information as environment variables in a different specific format. This library handles mapping the variables to the format Symfony Flex expects for common values.


Simply require this package using Composer. When Composer's autoload is included this library will be activated and the environment variables set. As long as that happens before Symfony bootstraps its configuration (which it almost certainly will) everything should work fine with no further user-interaction necessary.

composer require platformsh/symfonyflex-bridge

Mappings performed

  • If a relationship named database is defined, it will be taken as an SQL database and mapped to the DATABASE_URL environment variable for Symfony Flex. (Note: Due to a bug in Doctrine, the code currently assumes MariaDB 10.2 as the service version. If that Doctrine bug is ever resolved this hard-coding can be removed.)

  • The Symfony Flex APP_SECRET is set based on the PLATFORM_PROJECT_ENTROPY variable, which is provided for exactly this purpose.

  • The MAILER_URL variable is set based on the PLATFORM_SMTP_HOST variable. That will be used by SwiftMailer if it is installed. If not installed this value will be safely ignored.

  • If no APP_ENV value is set, it will default to prod.


If a relationship named elasticsearch is defined, it will be taken as an Elasticsearch index and mapped to appropriate environment variables. Most Elasticsearch packages for Symfony do not have a standard naming convention for environment variables so you will need to modify your Symfony configuration to read them.

For the common Elastica library, you would add the following to your Symfony config/services.yaml file:

# config/services.yaml
  es_host: '%env(ELASTICSEARCH_HOST)%'
  es_port: '%env(ELASTICSEARCH_PORT)%'

And then you can reference those parameters in your Elastica configuration file:

# config/packages/fos_elastica.yaml
        default: { host: '%es_host%', port: '%es_port%' }


If a relationship named mongodatabase is defined, it will be taken as a Doctrine ODM database and mapped to the appropriate environment variables. Note that you may still need to reference those environment variables in your configuration if they are not defined by default. See the DoctrineMongoDBBundle documentation for more details.

Generally, placing the following in your doctrine_mongodb.yaml file should be sufficient:

# config/packages/doctrine_mongodb.yaml
            server: '%env(MONGODB_SERVER)%'
            options: { username: '%env(MONGODB_USERNAME)%', password: '%env(MONGODB_PASSWORD)%', authSource: '%env(MONGODB_DB)%' }
    default_database: '%env(MONGODB_DB)%'


If a relationship named rabbitmqqueue is defined, it will be taken as a RabbitMQ messenger backend and mapped to the appropriate environment variable.