The experts at Axelerant were recently working on a couple of Mautic plugins. The team preferred using Lando as a first local development environment setup choice because of its flexibility and other benefits.
Find how the team used Lando to set up a development environment for Mautic here.
Setting Up A Development Environment For Mautic
Follow the steps below to set up local Mautic development using Lando.
Step 1: Installing Lando
First, you need to install Lando in your system. Start by downloading the most recent version. Your current Docker Desktop version might get affected as Lando bundles a compatible Docker inside its setup.
Choose not to install the Docker Desktop if you wish to retain your current docker version. Refer to the Lando installation guide for more details.
Step 2: Mautic Installation
Once the Lando setup is done, it's time to clone the new Mautic repo and create the project. You can begin the setup by cloning the Mautic 3.x branch. Afterward, go to the directory and run the ‘lando init’ command to initiate the Lando setup.
Step 3: Lando Init
The Lando init command will initiate the lando installation and ask a few questions to set up the Lando application. Provide the following answers to the questions.
|From where should we get your app's codebase?||Select ‘current working directory’|
|What recipe do you want to use?||Select ‘lamp’ as there is no pre-backed recipe like Drupal 8 for Lando|
|Where is your webroot relative to the init destination?||Select ‘.’ to give the current directory. Depending on the project setup, different document roots can be provided|
Now it will ask for the application name. Once that is done, you are finished setting up, and your bare lando.yml file will look like this.
Extending And Tooling Support
Specific PHP and MySQL versions are typically used to ensure exact matches between production and local stacks. You can do this by adding the versions.
In some cases, you might have to add additional PHP extensions. Make sure to specify that in the additional section for services. You must also add other services like XDebug for debugging.
This section specifies additional PHP configuration via php.ini specific to the project. To do this, create a directory called '.lando' in the project root and place the php.ini file in the 'php' directory.
- docker-php-ext-install sockets
Refer to this repository to check the code for php.ini.
While working in Mautic, you can check and view the sample emails locally by configuring Mailhog.
You need to run 'lando ssh' for Mautic's console commands or use the tooling to run those without ssh. If you opt for the latter, add the 'tooling' section in Lando, relevant services, and commands.
Finally, to complete this setup, run the 'lando start' command to start the Lando. Your final lando.yml will look like this.
During Mautic installation, you will need database-related information, which can be accessed by running the ‘lando info’ command. The database information for the current example used is given below.
Database name: 'lamp'
User name: 'lamp'
The information for Mailhog is given below as well.
Host: 'mailhog' Port: '1025'
This information can be used for setting up email support in the third step of the installer. Once Mautic is up and running, users can run a few console-related commands like cache:clear and mautic:segments:update.
These commands can be directly run using a custom command named ‘mt.’ Running ‘lando mt’ will equal ‘php bin:console’ inside the container. To access all the logs from the app, run the ‘lando logs’ command.
Users can also extend Lando according to new requirements and additional tooling support by referring to the basic steps for running the Mautic website. You can explore further by referring to the Lando documentation.