Lando Commands

Lando offers a local development environment and... DevOps tool built on Docker container technology.  See more
Action Command
INSTALL # First check system requirements
Check System Requirements

# Download & install latest version supporting your machine
GitHub releases Download Lando (Latest)

Note:
While running the installer, install the suggested Docker as well, there might be a change that you have the latest Docker but the Lando is not supporting it.
Also, refrain updating Docker separately or Lando may trouble you.
INSTALL DRUPAL # Create a new Drupal project
mkdir /path/to/drupal/project
cd /path/to/drupal/project

# Initialize Lando
# A '.lando.yml' configuration file will be created
lando init
? From where should we get your app's codebase? current working directory
? What recipe do you want to use? drupal8
? Where is your webroot relative to the init destination? web
? What do you want to call this app? myproject

# Start Lando to prepare composer, drush, appserver, database, hostnames etc. for drupal project
# It will read the '.lando.yml' configurations and prepare the depedencies
lando start

# [Option 1] A fresh new Drupal code base
# Create drupal project via composer in a temporary directory (because, composer won’t install if not an empty directory and here we had ‘.lando.yml’)
lando composer create-project drupal/recommended-project tmpdrupal

# OR [Option 2] Drupal code base from existing GIT repository
# Further, this option may require composer install to execute
# Clone repository in a temporary directory (because, git also won’t clone if not an empty directory)
git clone <repository_url> tmpdrupal
cd tmpdrupal
lando composer install
cd ..

# Now, move all ‘tmpdrupal’ files to current directory and delete ‘tmpdrupal’ directory/files
mv tmpdrupal/* tmpdrupal/.* .
rm -rf tmpdrupal

# Now, find out your project hostname or site-name (in general, it is http://myproject.lndo.site)
lando info

# Now visit http://myproject.lndo.site in browser to configure and install Drupal
# It is usual Drupal installation; with below fixed inputs while configuring database:
Database name: drupal8
Database username: drupal8
Database Password: drupal8
Host: database (Expand 'Advance Options' to mention)

Note: Here localhost is ‘database’, and why all inputs 'drupal8'?, actually it is the recipie name you chosen while inializing Lando with 'lando init' command earlier
CONFIGURATIONS # A '.lando.yml' file is at the heart of every Lando app like .git folder
# Configure, manage or add new service in .lando.yml file
# A normal .lando.yml for Drupal-8 project looks somewhat like:
name: myproject
recipe: drupal8
config:
  webroot: web
proxy:
  mailhog:
    - mail.d8loc.lndo.site
  pma:
    - pma.d8loc.lndo.site
services:
  mailhog:
    # Use the latest mailhog version
    type: mailhog
    # List of services that we want to capture mail from
    # You can run `lando info` to get a list of services that are available
    # Mailhog expects that these services will be php services
    hogfrom:
      - appserver
    # Optionally allow access to the smtp service at localhost:1026
    # You will need to make sure port 1026 is open on your machine
    #
    # You can also set `portforward: true` to have Lando dynamically assign
    # an open port. Unlike specifying an actual port setting this to true will give you
    # a different port every time you restart your app
    portforward: true
  pma:
    type: phpmyadmin:4.7

Note:, you need to run 'lando rebuild' if updated .lando.yml file
GENERAL LANDO # Check Lando version
lando version

# Displays the lando configuration
lando config

# Initializes a lando project, further creates a .lando.yml file
lando init

# Get project/app information
lando info

# Start your project/app
lando start

# Check all currently running lando project/apps
lando list

# Restart your project/app
lando restart

# Stop your project/app
lando stop

# Rebuilds your project/app from scratch, preserving data; required when you update .lando.yml file
lando rebuild

# Destroys your project/app and release machine memory
lando destroy

# Clear lando tasks cache
lando --clear

# Runs with extra verbosity
lando <command> -v
lando <command> --verbose

# Execute non-interactively; say all YES!
lando <command> -y

# List all commands and options
lando

Note: If you will miss 'lando' prefix while running the command, it will try to run HOST machine's composer command, and may not output desired result
DATABASE SERVICE # Imports a database dump into a database service
# Important: Database dump must reside within the project/app directory
lando db-import <db_dump_file>
lando db-import dump.sql
lando db-import dump.zip

# Exports database from a database service to a file
lando db-export <db_dump_file>
lando db-export dump.sql
RUN MYSQL # Execute from MySQL Shell
lando mysql

# Exit MySQL Shell
exit
quit

Note: If you will miss 'lando' prefix while running the command, it will try to run HOST machine's mysql command, and may not output desired result
RUN PHP # Run php commands
lando php <command>

Note: If you will miss 'lando' prefix while running the command, it will try to run HOST machine's php command, and may not output desired result
RUN COMPOSER # Run composer commands
lando composer <command>

Note: If you will miss 'lando' prefix while running the command, it will try to run HOST machine's composer command, and may not output desired result
RUN DRUSH # Run php commands
lando drush <command>

Note: If you will miss 'lando' prefix while running the command, it will try to run HOST machine's drush command, and may not output desired result
RUN DRUPAL CONSOLE # Run php commands
lando drupal <command>

Note: If you will miss 'lando' prefix while running the command, it will try to run HOST machine's drupal command, and may not output desired result
LANDO SHELL # Enter appsever shell for more control
lando ssh

# Also, you can run composer, drush etc. commands without the 'lando' prefix, just like we do in Vagrant
composer require <vendor>/<package>
drush <command>
LOGS # Displays logs for your app
lando logs

# Displays logs service specific
# For service name execute 'lando info' command
lando logs -s <service>
lando logs -s database
lando logs -s appserver
HELP # Enter appsever shell for more control
lando <command> --help

Comments

  1. Installing site via drush

    lando drush si

    Database name [drupal]:
    > drupal9

    Database driver [mysql]:
    >

    Database username [drupal]:
    > drupal9

    Database password [drupal]:
    > drupal9

    Database host [127.0.0.1]:
    > database

    Database port [3306]:
    >

    ReplyDelete
    Replies
    1. In one line -
      lando drush si standard --account-pass=admin --db-url=mysql://drupal8:drupal8@database/drupal8
      lando drush si standard -y --account-pass=admin --db-url=mysql://drupal8:drupal8@database/drupal8

      Delete
    2. drush si --db-url=mysql://root:pass@localhost:port/dbname^

      Delete
  2. Citation*
    mail.d8loc.lndo.site shall be mail.myproject.lndo.site

    ReplyDelete

Post a Comment

Drupal Contribution
Git Commands
RESTful Services
Lando Commands
Docker Commands
MySQL
Database Quick Code
Drush Commands
Drupal Console
PHP Quick Code
Drupal Quick Code
Composer Commands
Linux Commands
Linux Shell Scripting
Drupal Hooks
Twig Tricks
PHPUnit Test
PhpMyAdmin
Drupal Constants
CSS Clues
BLT Commands
Vagrant Commands
Localhost
127.0.0.1
Drupal Interview
Drupal Certifications
Concept & Definitions
Mac Tips
Windows Tips
Browser Tips

Best Practice

Use 'elseif' instead of 'else if'
#CodingTips

As of PHP 5.4 you can also use the short array syntax, which replaces array() with []
#CodingTips

Functions in general shall be named using snake_case(say, my_function()), and using camelCase(say, myFunction()) when declared within a plugin class
#CodingTips

Variables in general shall be named using snake_case(say, $my_variable), and using camelCase(say, $myVariable) when declared within a plugin class
#CodingTips

Manage automatically assigning of new permissions whenever a module is enabled here- admin/config/people/accounts
#ConfigurationTips

Manage source of Main-menu and User-menu links here- admin/structure/menu/settings
#ConfigurationTips

Helper function(s) shall be named prefixing an underscore(say, _my_helper_function()), which can prevent hooks from being called
#CodingTips

Ideally, configuring of 'Private file system path' at admin/config/media/file-system should be located outside of your Drupal root folder(say, ../my_private_files)
#ConfigurationTips

You should be aware that uploading files as 'Private file' will slow down the process of loading the files as Drupal has to be bootstrapped for every file that needs to be downloaded
#ConfigurationTips #BeAware

Code should always be pushed up(dev -> staging -> production) and databases should only be pushed down(production -> staging -> dev)
#DevelopmentTips

Get Raw SQL Query of drupal dynamic queries before executing it using $query->__toString();
#DebugTips

In VI-Editor, Press ESC key to come in command mode and for undo type :U and for redo type :Ctrl+R
#LinuxTips

Insert queries must always use a query builder object(layer of abstraction), allowing individual database drivers special handling for column values (if applicable), example case for LOB and BLOB fields.
#DatabaseQueryTips

Drupal uses the .inc extension to prevent files from being executed directly.
#DevelopmentTips

Popular Posts