While Lando recipes set sane defaults so they work out of the box they are also configurable.

Here are the configuration options, set to the default values, for this recipe. If you are unsure about where this goes or what this means we highly recommend scanning the recipes documentation to get a good handle on how the magicks work.

recipe: symfony
  php: '7.4'
  via: apache:2.4
  webroot: .
  database: mysql:5.7
  cache: none
  xdebug: false
    database: SEE BELOW
    php: SEE BELOW
    server: SEE BELOW
    vhosts: SEE BELOW

Note that if the above config options are not enough all Lando recipes can be further extended and overriden.

Choosing a php version

You can set php to any version that is available in our php service. However, you should consult the Symfony requirementsopen in new window to make sure that version is actually supported by Symfony itself.

Here is the recipe config to set the Symfony recipe to use php version 7.3

recipe: symfony
  php: '7.3'

Choosing a web server

By default this recipe will be served by the default version of our apache service but you can also switch this to use nginx. We highly recommend you check out both the apache and nginx services before you change the default via.

With Apache (default)

recipe: symfony
  via: apache

With nginx

recipe: symfony
  via: nginx

Choosing a database backend

By default, this recipe will use the default version of our mysql service as the database backend but you can also switch this to use mariadb or 'postgres' instead. Note that you can also specify a version as long as it is a version available for use with lando for either mysql, mariadb or postgres.

If you are unsure about how to configure the database, we highly recommend you check out the mysql, mariadband 'postgres' services before you change the default.

Using MySQL (default)

recipe: symfony
  database: mysql

Using MariaDB

recipe: symfony
  database: mariadb

Using Postgres

recipe: symfony
  database: postgres

Using a custom version

recipe: symfony
  database: postgres:14

Choosing a caching backend

By default this recipe will not spin up a caching backend.

However, you can specify one using the cache recipe config and setting it to use either our use redis or memcached service. Note that you can optionally/additionally specify a particular version for either as long as it is a version documented as available for use with lando for either service.

If you are unsure about how to configure the cache we highly recommend you check out our redis and memcached) docs as well as the Symfony onesopen in new window.

recipe: symfony
  cache: redis

Using Memcached

recipe: symfony
  cache: memcached

Using a custom version

recipe: symfony
  cache: redis:2.8

Environment File

By default, Symfony comes with a .env configuration file. You will want to modify the following .env key so that it makes sense for use with Lando.

Here is what that file would look like if you installed symfony as above. Note that your file might be slightly different depending on your configuration.

# In all environments, the following files are loaded if they exist,
# the later taking precedence over the former:
#  * .env                contains default values for the environment variables needed by the app
#  * .env.local          uncommitted file with local overrides
#  * .env.$APP_ENV       committed environment-specific defaults
#  * .env.$APP_ENV.local uncommitted environment-specific overrides
# Real environment variables win over .env files.
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).

###> symfony/framework-bundle ###
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Configure your db driver and server_version in config/packages/doctrine.yaml
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
###< symfony/swiftmailer-bundle ###

Connecting to your database and/or cache

Lando will automatically set up a database with a user and password and also set an environment variables called LANDO INFO that contains useful information about how your application can access other Lando services.

Here are is the default database connection information for a Symfony site. Note that the host is not localhost but database.

database: symfony
username: symfony
password: symfony
host: database
# for mysql
port: 3306
# for postgres
# port: 5432

If you've also specified a caching backend here are the default connection settings.

host: cache
# Redis
port: 6379
# Memcache
port: 11211

You can get also get the above information, and more, by using the lando info command.

Using custom config files

You may need to override our default Symfony configopen in new window with your own.

If you do this you must use files that exists inside your applicaton and express them relative to your project root as below.

Note that the default files may change based on how you set both ssl and via. Also note that the vhosts and server config will be either for apache or nginx depending on how you set via. We highly recommend you check out both the apache and nginx if you plan to use a custom vhosts or server config.

A hypothetical project

Note that you can put your configuration files anywhere inside your application directory. We use a config directory in the below example but you can call it whatever you want such as .lando.

|-- config
   |-- default.conf
   |-- my-custom.cnf
   |-- php.ini
   |-- server.conf
|-- index.php
|-- .lando.yml

Landofile using custom symfony config

recipe: symfony
    database: config/my-custom.cnf
    php: config/php.ini
    server: config/server.conf
    vhosts: config/default.conf