As, i have posted how to start working with lando for drupal 8, drupal 9 projects from the scrach.
But when we have existing projects, then how to setup with lando.
Today i am goining to write a simple blog to setup exisitng project with lando, step by step.
Let’s started.
Note: Make sure, you must have install lando.
Related.
You can install new Drupal 9 site using composer with lando.
Upgrade drupal core 8.7 core to drupal recommended 8.9.19
Step 1: download your source code and put it on you Lando Root directory.
Step 2: Create .lando.yml in root of your project and paste the below code.
name: khaitan9update
recipe: drupal8
config:
webroot: web
php: '7.4'
composer_version: '2.1.9
- name: Name of Your codebase
- recipe: Drupal 8, because this project build in drupal8, we will update it drupal 9 later.
- webroot: web which is web root directory.
- you can specify php version as well composer_version.
Step 3: Create settings.lando.php file inside web/sites/default and paste the below code.
<?php
/**
* @file
* Lando settings.
*/
// Configure the database on Lando
// FROM https://github.com/thinktandem/platformsh-example-drupal8/blob/master/web/sites/default/settings.lando.php
// Set the database creds
$databases['default']['default'] = [
'database' => 'drupal8',
'username' => 'drupal8',
'password' => 'drupal8',
'host' => 'database',
'port' => '3306',
'driver' => 'mysql',
'prefix' => '',
];
// And a bogus hashsalt for now
$settings['hash_salt'] = json_encode($databases);
global $content_directories;
$content_directories['sync'] = $app_root.'/../content/sync';
Step 4: add below code in setting.php file which is web/sites/default.
if (getenv('LANDO')) {
if (file_exists($app_root . '/' . $site_path . '/settings.lando.php')) {
include $app_root . '/' . $site_path . '/settings.lando.php';
}
}
Step 5: run below command.
lando start
Step 6: Now import db for connecting CMS to database.
lando db-import dbkhaitan-19-10-2021.sql
Note: make sure if, lando db-import dbname, will not work then run lando rebuild -y
Step 7: Now, you can able to access your CMS, just login and use it.