Configuration

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's Landofile. 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: backdrop
config:
  php: '7.4'
  composer_version: '2.0.7'
  via: apache:2.4
  webroot: .
  database: mysql:5.7
  backdrush: '1.0.0'
  xdebug: false
  config:
    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 Backdrop requirementsopen in new window to make sure that version is actually supported by Backdrop itself.

The recipe config to set the Backdrop recipe to use php version 5.5 is shown below:

recipe: backdrop
config:
  php: '5.5'

Choosing a composer version

You can set composer_version to any version that is available in our php service.

recipe: backdrop
config:
  composer_version: '1.10.1'

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: backdrop
config:
  via: apache

With nginx

recipe: backdrop
config:
  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 instead. Note that you can also specify a version as long as it is a version available for use with lando for either mysql or mariadb.

If you are unsure about how to configure the database, we highly recommend you check out both the mysql and mariadb services before you change the default.

Also note that like the configuration of the php version, you should consult the Backdrop requirementsopen in new window to make sure the database and version you select is actually supported by Backdrop itself.

Using MySQL (default)

recipe: backdrop
config:
  database: mysql

Using MariaDB

recipe: backdrop
config:
  database: mariadb

Using a custom version

recipe: backdrop
config:
  database: mariadb:10.2

Connecting to your database

Unlike other unnamed php-based CMSes, Backdrop's database connection information can be set by an environmental variable named BACKDROP_SETTINGSopen in new window. Lando will set this variable for you which means that unless you explicitly hijack the default functionality, you should not need to do anything to configure your database connection.

You can also examine and use this variable in-code similarly to how you would with LANDO_INFO.

lando php -r "print_r(getenv('BACKDROP_SETTINGS'));"
# {"databases":{"default":{"default":{"driver":"mysql","database":"backdrop","username":"backdrop","password":"backdrop","host":"database","port":3306}}}}

If you find that you still cannot connect to your database, the default information about your Backdrop database is shown below:

Note that the host is not localhost but database.

database: backdrop
username: backdrop
password: backdrop
host: database

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 Backdrop configopen in new window with your own.

If you do this, you must use files that exist inside your application and express them relative to your project root as shown 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 but you can call it whatever you want such as .lando in the example below:

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

Landofile using custom backdrop config

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