Magento is great (yes, really—and you probably think so too, otherwise you wouldn’t be here!). But installing Magento locally for the first time can quickly become long and complicated. Between Nginx, Varnish, Redis, MariaDB, etc., that’s a lot of services to set up!
You could spend the whole day creating and fine-tuning your Docker images, configuring each container one by one, and doing it all over again with every update (I can feel your excitement already!). Or… you could use Warden.
Warden?
David Alger published Warden on GitHub on June 3, 2019 (see here). The goal is simple: let you spin up dev environments via Docker containers, quickly and painlessly. Today, Warden supports several stacks: Magento 1/2, Symfony, Laravel, WordPress, and more.
The concept is even simpler: you choose your environment. Warden generates a .env
file for you. You fill in your versions. You run one magic command… and bam. All your containers are created, and your environment is up and running.
How do I set it up on my machine (or with my team)?
Warden works on Linux, macOS, and Windows. But if you’re on Windows, you **must** install WSL (Windows Subsystem for Linux).
Then, install Docker Desktop (or just Docker depending on your OS), followed by Homebrew, or clone the Git repo and make it executable. Once that’s done, run:
warden install
And that’s it—Warden is now ready to go on your machine.
You can also enable automatic DNS resolution and generate self-signed certificates. Feel free to explore those options based on your needs.
And for Magento, how do we proceed?
Once Warden is installed, let’s move on to Magento 2.
First, I create a project folder:
mkdir -p ~/Sites/myproject cd ~/Sites/myproject
Then I initialize the environment:
warden env-init myproject magento2
Warden generates the necessary files, including a .env
file. Next, I sign the SSL certificate:
warden sign-certificate myproject.test
Make sure the domain used here matches the TRAEFIK_DOMAIN
variable in the .env
file.
Then I start the environment:
warden env up
If you get a “Mounts denied” error, just follow the on-screen instructions. It’s usually a permissions issue. Once that’s resolved, re-run the command.
Next, I enter the PHP container:
warden shell
Before fetching Magento, I configure Composer with my Marketplace credentials:
composer global config http-basic.repo.magento.com <public_key> <private_key>
Then I download Magento:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition /tmp/magento2 2.4.6
I copy the files to the web folder:
rsync -a /tmp/magento2/ /var/www/html/ rm -rf /tmp/magento2/
And finally, I run the install:
bin/magento setup:install \ --base-url=https://app.myproject.test/ \ --db-host=db \ --db-name=magento \ --db-user=magento \ --db-password=magento \ --backend-frontname=admin \ --admin-firstname=Admin \ --admin-lastname=User \ --admin-email=admin@myproject.test \ --admin-user=admin \ --admin-password=Admin123! \ --amqp-host=rabbitmq \ --amqp-port=5672 \ --amqp-user=guest \ --amqp-password=guest \ --search-engine=opensearch \ --opensearch-host=opensearch \ --opensearch-port=9200 \ --opensearch-index-prefix=magento2 \ --opensearch-enable-auth=0 \ --opensearch-timeout=15 \ --session-save=redis \ --session-save-redis-host=redis \ --session-save-redis-port=6379 \ --session-save-redis-db=2 \ --cache-backend=redis \ --cache-backend-redis-server=redis \ --cache-backend-redis-db=0 \ --cache-backend-redis-port=6379 \ --page-cache=redis \ --page-cache-redis-server=redis \ --page-cache-redis-db=1 \ --page-cache-redis-port=6379
And done. Magento is now running locally in a clean, stable, and reproducible environment.
To wrap up
Thanks to Warden, you can forget the endless setup struggles and focus on what matters most: coding. Yes, there’s a bit of configuration at the start, but honestly, the convenience that follows makes it a fantastic time investment.
Now that everything’s running locally, all that’s left is to launch your favorite IDE (#team Word for me, like every dev ninja!), prepare a few liters cups of coffee… and code in peace.