Over time, the versions of many libraries or applications evolve and often one machine is not sufficient to host all the versions simultaneously, an example may be the php library which in a couple of years has changed version from 5. X at the current 7.x and installing them both and managing them is not at all easy, here is the concept of virtualization. Rather than running real virtual machines, today we have a powerful and versatile tool called Docker. Leaving aside the advantages and the guides on how to install it, we pass directly to the real case.

I have a PC with Ubuntu operating system, Lamp installed and (to date, when I write this article) the installed php version is 7.2 I’m also a fanatic supporter of the well-known Yii framework so I created N applications on this machine, some created both with Yii 1.x (php 5.x compatible) and others with Yii 2.x (php 7.x compatible). What happens if they ask me for an update or a change to the code of an application made with Yii 1.x ? I’ve to continuously switch between the two versions of the Php (5.x <-> 7.x) this step as well as boring, takes away a lot of precious time.


The solution to this paradigm is to virtualize with Docker Containers, ad hoc environments created to run what we want, in this case, I looked for a container with features very similar to my work environment (apache, php, mysql and a system operating linux based) in a few minutes I have an environment (guest) isolated from my machine (host) that will allow me to continue working even with older versions of php.

Let’s start by cloning this amazing github repository, read the README which explains how to create and finally launch the docker-compose and very interesting detail is the ability to change branches based on the php version that you want to install in the Docker container.

At the end of the docker composer execution we will finally have all the containers started and ready for use.
Another interesting detail is the “www” folder that we will find in our cloned repository, which is nothing more than the documentRoot of our (virtual) webserver all that will be contained within it will be executed by apache. This feature in Docker terminology is called Volume.

Clone your app

Now that we have a completely new documentRoot and isolated from the rest of the host machine, we just have to clone our applications (in my case I cloned one of my applications for edit/upgrading and the well-known “Yii 1.1.x” framework without which my application would not run properly) in the folder named ‘./www’.

cd cloned-repo/www/

git clone https://github.com/my-user/myAppWith_Old_php.git

git clone https://github.com/yiisoft/yii.git

Localhost it's ready!

Finally we can see the result of so much effort, we open the browser and write this url ->


we should see our application running smoothly!!

Lascia un commento

Il tuo indirizzo email non verrĂ  pubblicato. I campi obbligatori sono contrassegnati *

Post comment