Recently we started working on a couple of Mautic plugins. At Axelerant, we typically use Lando as a first local development environment setup choice due to its flexibility and several other benefits.
Today, we will do a quick walkthrough of using Lando to set up a development environment for Mautic.
First, we need to install Lando in our system; you can download the most recent version from here. Typically, Lando bundles compatible Docker setup inside its setup, so your current Docker Desktop version might get affected.
Once we are done with the Lando setup, it’s time to clone the fresh Mautic repo and create the project. We will clone the Mautic 3.x branch and begin the installation.
Once we are done cloning the repository, go to the directory and run the “lando init” command to initiate the Lando setup.
Lando init command will initiate the Lando installation, and it will ask a few questions to set up the Lando application:
- From where should we get your app's codebase => select “current working directory”
- What recipe do you want to use? => select “lamp”, as we don’t have a pre-backed recipe like Drupal 8 for Lando
- Where is your webroot relative to the init destination? => select “.” to give the current directory. You can provide different docroot depending on your project setup
Now it will ask for the application name, and we should be done with the setup after that.
After the above setup, our bare lando.yml file will look like this:
Extending and tooling support
Typically, we work with specific PHP and MySQL versions so that our local exactly matches our production stack. So, we will add those versions.
In some cases, we need to add additional PHP extensions, so we need to specify that in the additional section for services. Apart from that, we need to add additional services like XDebug, etc. so that we can use it for debugging.
In this same section, we can specify additional PHP configuration via php.ini specific to our project. So create a directory called “.lando” in the project root and place the php.ini file in the “php” directory.
You can refer to this repo to check the code for php.ini.
While working in Mautic, we frequently need to check the sample emails, so to check and view those emails on local, we can configure Mailhog
Typically, we need to do “lando ssh” to run the Mautic’s console commands. Instead, we can use the tooling to run those without doing ssh.
For that, we need to add the “tooling” section in Lando and add relevant service and command.
So our final lando.yml will look like this:
Once we are done with this step, run the “lando start” command to start the Lando.
Getting other information
During Mautic installation, you will need database related information. We can get it by running the “lando info” command.
So in our case database, this information is given below:
- Database name: 'lamp',
- Password: 'lamp',
- User name: 'lamp'
- Host: 'database',
- Port: '3306'
Also, we can get Mailhog related port information as well.
Host: 'mailhog', Port: '1025'
- We can use this information in setting up email support in the third step of the installer.
- Once we are up and running with Mautic, typically, we need to run a few console related commands like cache:clear, mautic:segments:update, etc.
- We can directly run those by using our custom command named “mt”.
- By running, “lando mt” will be equal to “php bin:console” running inside the container.
“lando logs” command will provide all the logs from the app.
As we went through the necessary steps to run the Mautic website on Lando, you can extend the Lando as per new requirements and additional tooling support. Lando documentation is an excellent place to start the exploration.
If you need help with Mautic development services, always choose an agency that has experience with Mautic and other open source technologies, so that they can engineer result-driven experiences.