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 Fletcher17 Feb 2024
How to update installed Python packages
You can use the pip list --outdated command to view a list of installed Python packages that have newer versions available. This command will show you which packages are outdated and can be updated to the latest versions.Here's how you can use itpip list --outdatedThis command will display a list of...
Andrew Fletcher04 Feb 2024
Run Python within a Lando environment
To begin, note that Lando is often used for web development and it may not be optimised for running long-running Python scripts or applications. &nbsp;It's primarily designed to host web services, so if you have specific Python development requirements, you might want to consider using a dedicated...