Playing with Docker and Linked Containers


In my current job, I am starting the process to upgrade our PHP 5.4 application to a PHP 5.6 application (PHP 7 is not yet support by the majority of the 3rd party libraries we use). I have been tasked with building the staging server for use in testing our legacy application as well as our newer Symfony-based application. We are using an older version of MySQL as well.

At some point, we will want to experiment with PHP 7.x and later versions of MySQL or MariaDB. Yet, will we want to build a brand new server each time?

This seems like a perfect opportunity to play with Docker.

I had first looked at Docker a little over a year ago. I had tried to build a dev environment entirely from Docker, but it and I were not yet ready for each other. I could not see Docker as anything other than another way to launch a Vagrant box for development.

This weekend, I looked at Docker again. Now Docker includes a feature called "Docker Compose." This allows one to build a Docker manifest within a YAML file rather than as a complex command-line string.

I played. I looked at building a new Drupal 8 box with a separate MySQL server. As a docker-compose YAML file, this is pretty straight-forward:


  image: drupal
    - drupal_database:mysql
    - 8085:80
  container_name: drupal_database
  image: mariadb:5.5
    MYSQL_ROOT_PASSWORD: examplepass
    MYSQL_USER: user
    MYSQL_PASSWORD: password
    MYSQL_DATABASE: drupal_db

The above creates two Docker machines: "drupal8" and "drupal_database." The "drupal8" Docker machine is linked to the "drupal_database" which is running MariaDB 5.5. To launch this, I just run docker-compose up from the directory that contains this docker-compose.yml file. This is the equivalent to running:

docker run --name drupal_database \
  -e MYSQL_ROOT_PASSWORD=examplepass \
  -e MYSQL_USER=user \
  -e MYSQL_PASSWORD=password \
  -e MYSQL_DATABASE=drupal_db \
  -d mariadb:5.5

docker run --name drupal8 \
  -p 8085:80 \
  --link drupal_database:mysql \
  -d drupal

I was able to come up with a working docker-compose.yml file within 30 minutes. It took me much longer to come up with the right docker run statements to make two Docker containers and have the Drupal container link to the MySQL container. Natch, had I read further down the Docker Hub Drupal page, I would have been given a huge clue as to how to connect the two; I just needed to add the appropriate port. Nonetheless, the YAML is much easier me to configure and update than the two docker run commands are.

Tags: php, docker, mysql, drupal

Last Month in PHP: 2015 December


From a KCPUG lightning talk given on 06 Jan 2016

December was a busy month in PHP. A major update to PHP was released, PHP-FIG approved a new PSR, major CMSes had major releases and/or were patched, and frameworks had major, minor, and patch releases.

PHP 7.0.1

PHP 7.0 was released on 3 December and was patched to 7.0.1 two weeks later. PHP 7 includes many new improvements, including:

  • speed!
  • Scalar type hinting
  • Return type declarations (optional)
  • New operators:
    • Null coalescing: ??
    • Spaceship: <=>
  • Constant arrays
  • Anonymous classes

See PHP 7 New Features for more information.

PSR-6 Caching Interface

PSR-6 ensures a common interface for caching support in PHP, for those libraries and frameworks that utilize it.

  • Allows free-standing libraries to support caching of intermediary data without effort.
  • Provides a common interface for basic and intermediate-level caching needs.

On 8 December, this passed amidst controversy.

See PSR-6 for more information.

WordPress 4.4: "Clifford"

On 8 December, the new version of WordPress, aka "Clifford", was released.

Some of its new features:

WordPress 4.4 requires PHP 5.2.4+, although PHP 5.6+ is recommended.

See: WordPress 4.4 announcement for more information.

Drupal 8.0.1

Drupal 8 was released on 19 November and the first patch was released on 2 December.

New features of Drupal 8 include:

  • HTML 5
  • Out-of-the-box WYSIWYG editing
  • Built with modern PHP practices & Libraries:
    • Composer, Symfony2, Guzzle, Twig, etc.
  • REST web services

Drupal 8 requires PHP 5.5.9+.

See Drupal 8 for more information.

Slim 3.0 Microframework

Slim 3.0 was released on 7 December.

New features of Slim 3.0 include:

Slim 3.0 requires PHP 5.5+

Symfony framework

Symfony 3.0 was released on 30 November and was patched to 3.0.1 on 26 December.

New features of Symfony 3 include:

  • Locale has been supplanted by Intl
  • Simplified security
  • Simplified voters
  • Monolog Bridge is now PSR-3 compatible
  • Changes in the ways Property Access, Routing, Logging, Translator, Twig, Validator, Yaml, Process, & Swiftmailer, Config, & more are used

Symfony 3 requires PHP 5.5.9+


  • Symfony 3.0.1
  • Symfony 2.8.1
  • Symfony 2.7.8
  • Symfony 2.3.36

Laravel 5.2 framework

Laravel 5.2 was released on 21 December.

New features of Laravel 5.2 include:

  • Auth Scaffolding
  • Implicit model bindingAppending output from scheduled tasks
  • Form array validation
  • Collections wildcards
  • Database Session Driver
  • Middleware Groups
  • Rate Limiting
  • Eloquent Global Scope

Virtual Machine: Laravel Homestead 5.2

Now with:

  • PHP7
  • Composer
  • git

Requires PHP 5.5.9+

See: Homestead 5.2

Upcoming Conferences

Sunshine PHP Feb 4-6: Miami, FL

Midwest PHP Mar 4-5: Minneapolis, MN

Lone Star PHP Apr 7-9: Dallas, TX

php[tek] May 23-27: St Louis, MO


NomadPHP is an online supplement to your in-real-life user group.

Jan 21: 01:00 PM CST Puli: PHP's Next Package Revolution - Berhard Schussek - @webmozart

Jan 21: 08:00 PM CST Building Better APIs - Mike Stowe - @mikegstowe

Tags: php, last month in php, kcphpug

Expectation vs Reality: my first 1.5 years of professional programming


I have been a professional developer for over a year and a half now.

About a year ago, my friend and mentor, John Kary, asked me how the job measured up to my expectations. I replied, honestly, that my expectations were met. However, I hadn't given it much thought since I was busy trying to learn so many new things. So, at the time, my expectation was that new developers spend a lot of time learning new things. Expectation: met.

Since that time, I have continued to learn new things, but I have also had time to think about the question more in depth.

I realized that I had many expectations of dev-life while I was studying programming.

Caveat: Your mileage may vary

Expectation 1 - Programming is a Young Man's Game

This was probably my largest fear with changing my career and entering programming as a full-time job. I had read too much about brogramming, sexism, and ageism being rampant in the development world. As a middle-aged dude, I was worried about entering this career that was run by 20-something guys that call each other "bruh."

Reality 1 - Programming is Open to All

My first interview for my job was with a female boss and a potential coworker who was older than me and was also female. I have told both of them since that this put my fears to rest and made the rest of the interview-process much easier. My second interview was with the team, which was made up of the female boss, the older-than-me female developer, a younger female developer, a remote guy via robot interface, a younger guy, and my friend, John Kary. Another member of the team was absent due to his grandson being born.

Since that time, we have hired a guy from Pakistan, a slightly younger guy, a slightly older guy, and a much younger guy. I would like to see more women apply for the job openings. Perhaps next time.

Expectation 2 - Programming Requires UML

My programming classes utilized UML, the various textbooks and other programming books also utilized UML. So, I imagined that dev meetings utilized UML on a dry-erase board.

Reality 2 - Learning Requires UML

In various team meetings, 1-on-1 dev meetings, and informal discussions, I have yet to see UML be utilized.

Expectation 3 - Developers Have a Computer Science Degree

I imagined developer discussions being in some meta-language that incorporated algorithms, Big-O notation, and obscure design patterns.

Reality 3 - Developers Come From All Walks of Life

Perhaps half of my team has some kind of Computer Science background and degree. Other members of my team have backgrounds in varied subjects from construction to film-studies.

In listening the various podcasts and attending various conferences and user-group meetings, I think that there is no fairly typical developer background. One can expect someone with a computer-science degree, but there are plenty of good developers out there without a degree, much less a computer-science degree.

Expectation 4 - Developers Are Invested In Their Community

I was a member of a developer community a decade before I became a professional developer. I have gone to developer conferences in Kansas City and Dallas and have met with many developers from those communities. I expected that all developers were interested in meeting with and working with developers from their community outside of their 9-to-5 job.

Reality 4 - Developers Come From All Walks of Life

I know that this is the same as #3; however, it fits here, too.

I have also met plenty of developers whom I have tried to recruit to join a local user group, yet they gave a non-committal "I'll look into it" when pressed. Most developers whom I have met are interested in programming for the 40-hours a week they are contracted to program. Outside of that time, they are interested in pursuing their own interests: wood-working, beer brewing, robot fighting, knitting, parade-float building, running, & etc.

Even for me, family is my number 1 priority. Yet, I devote time to organizing a PHP User Group, planning and mentoring a CoderDojo, and studying programming concepts and technologies outside of work.

Expectation 5 - If You Don't Play Reindeer Games, You Don't Belong

What I knew of programmers is what I knew from media and my nerd friends. Cards Against Humanity, Dungeons and Dragons, comic books, video games, Star Wars/Trek, and pop-culture ephemera rule developer society.

Reality 5 - Developers Come From All Walks of Life

Guess what? Developer !== Dork. You might know some developers who fall into that stereotype, but you probably know others who have interests outside of developer stereotypes.

I have yet to play Cards Against Humanity at work. Yet, I have played it once after a CoderDojo session. I have had several Star Wars/Trek discussions with coworkers, but not all coworkers.

At lunch, we mostly talk about family and recent events in our lives. I have recently started a dev book club with my team for a once-per-week lunch discussion. Some of us gather once per month for NomadPHP with a follow-up discussion.

Expectation 6 - Memes Are Huge

Before I got my job, I started reading reddit. One thing that I learned is that memes are huge. So I ran through a bunch of memes on meme generator.

Reality 6 - Memes Are Huge for Some

Memes are memes because they are memes. That's tautology for you.

Memes are drawn from popular culture. So, when I was a kid, saying "This is not the assignment you're looking for" was utilizing a meme. We just didn't call it that. 15 years ago, saying to a friend, "Wassup!" was utilizing a meme. We just didn't call it that.

So now, with the easy usage of emoji and the /meme command in HipChat, memes are all too easy to utilize in a textual discussion.

Yet, not all of us know what the heck some of these memes mean. And some don't even bother with using memes in textual discussion. Memes tend to be a shibboleth in a team when a team shouldn't require such watch-words or phrases.

Expectation 7 - Programmers are a Monoculture

When attending a conference, it's easy to see that the vast majority of attendees are younger white guys. The lines to the men's room are long whereas the lines to the ladies' room are non-existant. All programmers are heavy into nerd-core and oontz-oontz electronic music.

Reality 7 & Conclusion - Developers Come From All Walks of Life

This, I think, is the ultimate expectation. All of the expectations above reflect this expectation.

When I was a CS student, classmates were from various genders, sexual orientations, ethnic backgrounds, races, and religions. This expectation was already smashed.

When I joined the league of professional programmers, I met programmers from all walks of life: programmers who grew up dirt poor and programmers who grew up with plenty; programmers who grew up steeped in nerd-core and programmers who came about it quite accidentally.

I am a middle-aged white guy. Yet, I've only been in this game professionally for 1.5 years. I have a lifetime of experience behind me in jobs & a career other than programming. You could take a glance at me and think that I am the very model of a modern career programmer. Yet, you could not be more wrong.

Tags: omphaloskepsis, career