# Lando

# Create a local environment for WP (i.e. BitBucket Project)

  1. Create a new wp-config-local.php file (if there isn't one). *
  2. Add lando credentials
<?php
define('DB_NAME',          'wordpress');
define('DB_USER',          'wordpress');
define('DB_PASSWORD',      'wordpress');
define('DB_HOST',          'database');
define('DB_CHARSET',       'utf8');
define('DB_COLLATE',       '');
 /* 
  * Insert salts here
  * URL: https://api.wordpress.org/secret-key/1.1/salt
 */
define('WP_DEBUG', true);
  1. Generate and add salts (opens new window).
  2. In wp-config, make sure the local config file is being loaded.
  3. Add the .htaccess to the root directory. (touch .htaccess)
  4. Paste the following into the htaccess file:
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
  1. Start the server (from project root): lando start.
  2. Import the backup DB: lando db-import backup.sql.gz.
  3. Perform a search and replace on the local environment: lando wp search-replace <old-url.dusted> <new-url.lndo.site>

* Make sure there's a conditional statement for loading the wp-login-staging.php. i.e.

if (file_exists(dirname(__FILE__) . '/wp-config-local.php')) :
    require_once(dirname(__FILE__) . '/wp-config-local.php');
else :
    // main config credentials
endif;