Originally published at: https://www.mautic.org/blog/developer/local-mautic-development-with-ddev/
DDEV is an OS agnostic wrapper for Docker. Learn how to set up a local Mautic development environment using DDEV in this community blog article.
Thanks for this blog post. We will develop a plugin for Mautic for one of customers soon, and would like to work with the index_dev.php
in our dev environment, as mentioned in https://developer.mautic.org/#environments.
However, with DDEV we had to do the following things to get the dev
environment up and running:
- In
.ddev/config.yaml
, changenginx-fpm
toapache-fpm
- In
.htaccess
, replace
RewriteRule .? %{ENV:BASE}/index.php [L]
by
RewriteRule .? %{ENV:BASE}/index_dev.php [L]
If anyone has an easier solution to get the dev
environment working in DDEV, please share it at least we’re up and running for now!
@Woeler can you give any insights?
If you want to test Mautic with another project on DDEV (let’s call the two ddev projects “mautic” and “website”) and you want to call Mautic API from php on website, you need to create the file .ddev/docker-compose.override.yaml on website project with the following content:
version: '3.6'
services:
web:
external_links:
- ddev-mautic-web:mautic.ddev.site
Thank you so much for this! It all worked like a charm. One small thing: I could not run composer install
from my terminal on my MacOs Catalina.
This package requires php >=7.2.21
The workaround for me was to first ddev start
, then access the container with ddev ssh
and now composer install
worked perfectly.
Hope that helps someone.
yes, usually it’s better to run composer from ddev, as it’s more reliable and there are less probabilities to have some local issues
Nice one @fabio84! Another option to reach the API from another Docker container (e.g. another DDEV project) is to do an HTTP request to http://ddev-mautic-web/api/....
, I remember taking this approach from a while ago
In order to run unit tests with DDEV:
Create a .env file in your root directory:
# .env.test
DB_HOST=db
DB_PORT=3306
DB_NAME=mautictest
DB_USER=root
DB_PASSWD=root
MAUTIC_TABLE_PREFIX=
MAUTIC_ENV=test
MAUTIC_ADMIN_USERNAME=admin
MAUTIC_ADMIN_PASSWORD=mautic
Manually create the database mautictest
from inside the container (ddev ssh
):
login:
mysql --user=root --password=root
create db:
CREATE DATABASE mautictest;
Run tests
composer test -- --filter PageController