Why switch from Xampp to Docker, for PHP developers, my experience.
For the uninitiated, LAMP stands for:
- Linux
- Apache (OR Nginx , in that case it become LEMP stack).
- Mysql, MariaDB
- PHP, Perl or Python
Many LAMP developer prefer using XAMPP or MAMPP to setup a quick development environment. Some developers even prefer installing the stack directly on their linux machines, These are great and convenient approaches for most cases.
However, there are few issue that I have faced after using these:
- Switching PHP version between 5.5 , 5.6 or 7.1, 7.2 or 7.3 can get messy at times, when using XAMPP.
- Similarly MySql upgrade can have issues, when updating version.
- If not done correctly you can end up with multiple XAMPP setups.
- Adding extensions like ssh2/gnupg..etc in different version of XAMPP/PHP can become a tedious task.
- Directly installing LAMP on your Linux machine can open another can of worms, if not done correctly. Since there is not isolation between your Linux system and LAMP setup.
As a beginner , I have myself had to format my Linux system many a times, to solve partitions issues or broken Dependencies.
Docker to the rescue…
What is Docker ?
Simply said, Docker is a Containerization Software, that runs on the Docker Engine, This make it easier to create, deploy, and run applications by using containers.
Well then, What are Containers?
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
Well Docker is much more that this, and one of the leading technologies in the market place now, well there are lots of great articles out there on more advance topics. But with context to this Post, am just explaining few basic advantages of Docker.
How can Docker help LAMP developers?
- You can consider Docker as an isolated Container, where all process run in a sort of Sandbox.
- This isolation is the a great advantage for developers. You can setup something and if you make a mistake, no big deal you can destroy the Container and restart in few seconds.
- Docker is Cross-platform, it can run on Linux, Mac or Windows.
- You can replicate your exact production environment locally, if done correctly.
- You can find official PHP images for Docker right from php 5.6 all the way up to latest PHP releases.
- Switching PHP version OR adding extensions is streamlined & can be done via the Dockerfile.
- There are Docker image available for almost everything from PHP to Mongodb, Couchdb, Redis, Solr ..and many more..
- Integration & installation of these services is effortless.
- Docker image are immutable, meaning: the images are readonly and can be reused multiple times, in different setups.
Conclusion :
LAMP development is come a long way since Xampp, and Docker is a tool that will take it in to the future. Docker containerization is a vast & interesting topic, using it to setup a local environment will just be the tip of the iceberg.