My Profile Photo

Personal Webpage of David Duggins


Well, I was born on a normal day in July, 1981 and have been creating chaos ever since. Born in North Carolina, but raised in the aftermath of the Soviet Union, Kazakhstan, I have been messing around with computers nearly my entire life. I wrote my first program in assembly when I was 11. In my early teens I ran a BBS connected to Fidonet and started building a website for my band. In 1999 I was introduced to Linux, and it was love at first compile. I started my career in IT in the early 2000's doing IT for a Car Dealership in Charlotte NC. I wrote my first major web app in Cold Fusion (an ecom app) at that time. In 2006 I left Charlotte and moved down to Columbia where starting working as a developer, freelancer and consultant. Currently I am working as a freelance developer and DevOps consultant!!


Using Docker with PHP Composer

So in this installment, I will be talking about how to use PHP/Composer with Docker. I am currently having to work with a Mac for a contract. I could use homebrew and get PHP setup on the Mac, but I am having to deal with multiple versions of PHP and frankly, I really do not want to have to deal with PHP on a machine that is not really mine. I really do not even have to run php locally, I am using a dev docker container to serve up the site locally. So I really just need to be able to run Docker. It’s not a very difficult proprosal.

First thing we must do is prepare a few things in the bash or zsh rc file. I use ZSH, so this is in my .zshrc file, but it works also with .bashrc or .profile. Whatever you use!

So the first step is to make a function in our bashrc file:

function docker_this_directory() {
    docker run -it --network host --rm -v "$(pwd)":$1 -w $1 $(@:2)
}

Then we need to create the alias for composer.

alias composer="docker_this_directory /directory composer:latest"
© 2024 David Duggins. All rights reserved.