Skip to main content

Changes in your .env file

Connecting your app to the new environment you need to make some tweaks in your .env file.

Change your DB_HOST to database. If you use MySQL or MariaDB Lando will create a database named laravel for you with a user laravel and the password laravel. The database section in your .env should look like this:

DB_CONNECTION=mysql
DB_HOST=database
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=laravel

If you use Postgres the settings should look like this:

DB_CONNECTION=pgsql
DB_HOST=database
DB_PORT=5432
DB_DATABASE=laravel
DB_USERNAME=postgres
DB_PASSWORD=null

You will need to configure your cache driver accordingly to your settings. If you added Redis to your .lando.env for example you have to set your REDIS_HOST to cache and the section should look like this:

REDIS_HOST=cache
REDIS_PASSWORD=null
REDIS_PORT=6379

 

Some of the cool commands that Lando has with the configured services:

Note now that you are using lando, you need to stay in the environment and run lando command.  For example, lando composer update, rather than composer update.  But lets have a look through some of the common commands.

Start the development environment and all services:

lando start

Stop the development environment and all servies:

lando stop

Destroy the whole environment and removes all images from your disk. Caution: This will also delete your database and everything inside the storage folder:

lando destroy

Runs all the artisan commands inside the container, for example lando artisan migrate to migrate your database. This is very important because if you run php artisan migrate as you are used to, you will get an error because you can't reach the host database which we set as the DB_HOST in the .env file before. Lando configured the container in a way that they can reach that host internally:

lando artisan

Runs composer commands inside the container, for example composer install or composer add. Again it is very important to know the difference than just running composer install because you can have different composer version locally and in your Lando environment:

lando composer

Drops you inside a MySQL shell in your container:

lando mysql

Runs any PHP command inside your container. Again, remember that it could be a different PHP version than you have installed locally.

lando php

SSHs you inside your app container where your source code runs:

lando ssh

Importing and exporting databases:

Exports your database into a file:

lando db-export [file]

Imports a database dump into your database service:

lando db-import <file>

 

Related articles

Andrew Fletcher18 Mar 2024
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE,...