Plugins

Lando has an advanced plugin system that allows developers to add and extend Lando's core functionality. Here are a few examples of things you can do with plugins:

  1. Create CLI commands like lando danceparty
  2. Add services like solr, redis or ruby
  3. Add additional configuration options and functionality to .lando.yml
  4. Hook into various Lando runtime events to provide additional functionality.
  5. Print "A British tar is a soaring soul!" after every app is started.

Plugin Basics

Plugins give you access to the Lando API so that you can modify and/or extend Lando. Here is the part of the proxy plugin that adds some proxy config options to the Lando global config.

/**
 * This adds proxy settings to our config
 *
 * @name bootstrap
 */

'use strict';

module.exports = function(lando) {

  // Modules
  var _ = lando.node._;

  // Add in some high level config for our proxy
  lando.events.on('post-bootstrap', function(lando) {

    // Log
    lando.log.info('Initializing proxy');

    // Proxy defaults
    var defaults = {
      proxy: 'ON',
      proxyDomain: 'lndo.site',
      proxyDash: '58086',
      proxyHttpPort: '80',
      proxyHttpsPort: '443',
      proxyHttpFallbacks: ['8000', '8080', '8888', '8008'],
      proxyHttpsFallbacks: ['444', '4433', '4444', '4443']
    };

    // Merge config over defaults
    lando.config = _.mergeWith(defaults, lando.config, lando.utils.merger);

    // Grab the merged config
    var proxyConf = {
      proxy: lando.config.proxy,
      proxyDash: lando.config.proxyDash,
      proxyHttpPort: lando.config.proxyHttpPort,
      proxyHttpsPort: lando.config.proxyHttpsPort,
      proxyHttpFallbacks: lando.config.proxyHttpFallbacks,
      proxyHttpsFallbacks: lando.config.proxyHttpsFallbacks,
    };

    // Log it
    lando.log.verbose('Proxy initialized with config', proxyConf);

  });

};

Running your own plugins

To get your plugin working with Lando do two things:

  1. Add your plugin to the list in config.yml.
  2. Place your plugin into the correct location.

Lando looks for plugins in either the node_modules or plugins folder in three separate locations. If there are multiple instances of the same plugin, Lando will load the one found furthest down this list:

  1. The source directory.
  2. Inside of the sysConfRoot. For example /usr/share/lando on Linux.
  3. Inside of the userConfRoot. For example ~/.lando/ on macOS.

Where are sysConfRoot and userConfRoot?

Run lando config to find the location of these directories as they can be different.

Plugin Examples

Check out some of our core plugins for motivation in creating your own.

results matching ""

    No results matching ""