Setup a local development environment for Contao on Arch Linux

by manu

I started to use Contao again. After a five year hiatus I can clearly say, it is my favorite CMS nowadays. It still looks and feels the same after all those years, I really appreciate using it. Pages, articles, modules, content elements. Once you got to know about them you don't want to miss them anymore. The backend is probably the best part about it: It is convenient to use, has a11y literally built in and even allows one to navigate all of that with some handy keyboard shortcuts. I can't count the many times I control clicked on something I want to edit or save and close it the same way I'd do with vim.

And the best thing about it: It uses Symfony under the hood, one of the most popular PHP frameworks out there.

Contao meets Arch

Before using symfony we need to install PHP and composer. And a bunch of extensions.

sudo pacman -S php php-gd php-imagick php-sodium php-fpm composer

I've tried to use it without php-fpm before, but that didn't work out and I always ended up in an infinite loop of redirects (at least while using Contao).

The FastCGI Process Manager (FPM) also has to be configured first to use your own user.

In my case I changed the pool config in /etc/php/php-fpm.d/www.conf to:

user = manu
group = manu
listen.owner = manu
listen.group = manu

Next, we have to download the Symfony CLI. I just downloaded one of the binaries with wget, extracted the archive and moved it to a locations which is in my $PATH.

The Symfony Local Web Server

Following the guide, I enabled TLS and started the proxy:

symfony server:ca:install
symfony proxy:start

For every project's root, I attached a domain first once with

symfony proxy:domain:attach foo

and as soon as I want to start working on that project, I start the server with

symfony server:start

After installing Contao, make sure to set the entry point to use the https protocol. To get a list of projects and attached domain names, I usually run

symfony proxy:status

Now the only thing left to do is to tell our web browser about the proxy. Depending on your desktop environment, one can open those settings from the browser, but as I'm using none of the popular ones such as GNOME or KDE, my only choice left is to set an environment variable, which Google Chrome will pick up then. In my ~/.profile file I added:

export auto_proxy="http://M720q:7080/proxy.pac"

This will tell the browser to proxy requests through symfony first. Instead of just using localhost or 127.0.0.1 I decided to use my host name, which allows me to access my sites from any other device in my network (thanks to Tailscale, this even works when I'm not at home).

That's it! After a reboot you should now be able to develop your sites locally with Contao.

Back to the news overview