Tom Butler's programming blog

Why are you still using XAMPP?

tl;dr

If you are just looking for a quick and easy to set up docker development environment, click here.

Introduction

XAMPP is the Internet Explorer 6 of the Development Environment world. If you are using XAMPP you are living in 2006 and it's time to move on. There is zero excuse for using such dated technologies and ultimately it will only hinder your career opportunities.

I am a member of various PHP facebook groups and forums. With regularity I see novice (and sometimes more experienced developers) asking questions like "How do I use PHP 8 in XAMPP?" or "How can I run two different PHP version in XAMPP?". You are asking the wrong question you should be asking "Is XAMPP the right tool for the job?".

To those using XAMPP I have one statement and one question.

The statement: There is no genuine reason to use xampp, ever.

The question: Have you even tried anything else?

The answer to the question is invariably no. People using XAMPP today are the same kind of people who were still using Internet Explorer 6 well into the 2000s. It was the first thing they were introduced to and they never learned any better or bothered to look into better/alternative solutions. Unfortunately many books and tutorials inexplicably still teach XAMPP as the development environment of choice.

People claim it's "easier" but it's only "easier" insofar as it's what you are used to. It's actually a lot more difficult once you want to do something outside the very narrow scope of default configuration that XAMPP supplies.

Worse, you will eventually want to upload your site to a real server, at which point you'll need to do a lot of work ensuring that PHP versions are the same, configuration and PHP extensions are the same, database users are set up, etc. With XAMPP this process is frustrating and can result in sites just not working without significant changes to file paths, configuration files, etc. With Docker you can just upload the entire application, code and config, and the site will run exactly the same on the server as it does on your development machine.

Even in the early 2000s when it was arguably the simplest choice available I always discouraged people from using it because it gives you zero knowledge of how a web server is actually configured. And at at some point in your career as a PHP developer you'll need to put the scripts on a real web server. By 2010 when Vagrant came out, any pretense of "easier" went out the Window. You've had eleven years since an easier (and better in many, many ways) solution has been available. Why are you still using XAMPP in 2021? You probably don't have an answer other than "It's the only thing I'm familiar with".

So what should you be using instead? Docker. Docker is an enterprise solution and allows you to run the exact same configuration on your development machine and your real server, removing any issues you would otherwise encounter when putting your website live.

Docker itself isn't a direct replacement for XAMPP in that it doesn't contain any packages by default, Docker provides a way of very simply installing any packages you like. However, you can create a server using docker and someone else's existing configuration with two very simple commmands.

Let's compare XAMPP and Docker for a PHP development environment.

Development and production parity

Once you want to make your website live, XAMPP will come back and bite you because you won't know how to manage a real server and XMAPP's configuration will invariably be different to your server, resulting in questions like this, this, this, this, this or one of hundreds of other examples of this question that wouldn't have to be asked if these people were using Docker locally and on the server.

Is XAMPP "easier"?

The short answer is no.

Although the GUI may be negligibly simpler for starting and stopping the server, any other task is more difficult. The config files are in different places, you have no choice in software versions, you can't use different server software, installing PHP plugins is significantly more difficult. Once you want to run more than one site at the same time, Docker is a lot easier. Any config change in XAMPP is system wide, you can't easily make changes on a per-site basis.

And, as mentioned above, when you want to make your website live, things get much more complicated than using Docker because your server software, config and versions is different to your development environment.

Unless you are only developing locally and require the default configuration without even the slightest changes, Docker is easier than XAMPP by any metric you wish to use.

When I've had resistance to this statement in the past, it's been entirely from people who have never tried Docker for their development environment, if you're reading this in disagreement I can guarantee you're one of them.

XAMPP

Let's take a look at the pros and cons of XAMPP and Docker

ProsCons
A fairly simplistic GUI that looks like a VB6 program from 1998Configuration is global, you can only run one server configuration at a time
Changing versions of installed software is difficult e.g swapping from PHP 7 to PHP 8
Swapping out apache for nginx is impossible
Encourages you to use the very dated phpMyAdmin (seriously, use MySQL Workbench instead)
Installing PHP extensions is a pain unless they're packaged with XAMPP (e.g. try installing xdebug or imagick)
It's supposedly for development but inexplicably doesn't even come with xdebug enabled by default.
When you upload your website to a real server, it will likely be using a different PHP/Apache/etc version and may not work. There are a number of differences between Windows PHP and Linux PHP (which your server will almost certainly be running) which can cause things to break.
As your ability grows, you'll want to use tools like Composer, Git and PHPUnit. XAMPP makes this unnecessarily difficult.
Running multiple websites each with their own PHP version is difficult to set up.
Professional PHP developers do not use XAMPP. If you want to progress in your career and work for a professional software development agency you'll need to use professional tools. There's no reason not to have them on your CV because they're actually easier!
Developing with a valid SSL certificate is hard
You'll need to manually configure your server/php.ini when you upload your website
Moving a website to another development machine requires finding and editing global configuration files
If you're on Windows some PHP extensions will not work, others are difficult to install

Docker

ProsCons
Easy to set up (just type two commands)You have to use the command line
Very quick and easy to change PHP versions
You can run the same docker image on your server
You can run multiple websites with different PHP/server configurations
You can run multiple websites with different PHP/server configurations at the same time
A rogue PHP script cannot accidentally delete files on your computer
Uses the same configuration as your server. There is no chance that your site won't work when you upload it.
You'll be using a tool that is actually used in industry, and a requirement on most job applications
PHP extensions can be installed with the single line docker-php-ext tool that comes with the docker image (And for anyone reading this unfamiliar with Docker, it really isn't as hard as it sounds).

Conclusion

The only benefit of XAMPP is an ugly GUI that looks like it was designed for Windows 98. Are people avoiding things like Docker because it requries typing in commands? If so, I have some bad news for you: You won't get far as a programmer if you are afraid of the command line.

You'll very quickly need to use Git, PHPUnit and Composer. All command line applications!

It's very hard to understand why people are still using XAMMP in 2021 and it's a shame that tutorials and books still cover it. It's time to move on. XAMPP has had its day, it was a mediocre solution when it was new, it's a poor solution now.

There's literally no reason not to use Docker. Aside from the technical benefits, it's a requirement for any professional web development job and you'll need to learn it eventually. Why bother setting something up you'll need to replace fairly soon into your programming journey anyway? Start out the right way.

If you want to try docker for yourself click here for an example environment that's quick and easy to get running.

If you want to know a bit more about setting up an environment yourself, take a look at this article I wrote for sitepoint.