Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Stephan Hochdöfer:
Dockerizing GitLab Review Apps
Jun 07, 2017 @ 10:28:15

On the BitExpert blog Stephan Hochdöfer has written up a post showing how to "Dockerize" GitLab review apps to create a consistent platform for these self-contained environments.

Last year GitLab introduced the Review Apps feature. Review Apps are app environments that are created dynamically every time you push a new branch up to GitLab. As a bonus point the app environments are automatically deleted when the branch is deleted. Since we moved to using docker for quite a few of our projects I was keen on figuring out how to combine Docker and the GitLab Review Apps functionality as the documentation only mentions NGINX as a way to run Review Apps. As it turns out, it is rather simple to deploy docker containers as a Review App.

He describes the environment he needs and which tools he'll be using to perform the build of the environments. He then defines the sample GitLab configuration file including the "build" stage. He briefly explains the steps this follows then shows the configuration for the "deploy" step, grabbing the latest image from his Docker repo and running it. He ends the post with an "undeploy" stage that removes the Docker build automatically when the environment is no longer needed.

tagged: gitlab review application apps tutorial docker deploy undeploy

Link: https://blog.bitexpert.de/blog/dockerizing-gitlab-review-apps/

Master Zend Framework:
How to Go From Development to Deployment with Docker
Jun 01, 2017 @ 13:13:58

The Master Zend Framework series has posted the third part in their series covering deployment and development setups with Docker. In this latest article Matthew Setter builds on the knowledge from the first and second parts of the series and shows how to deploy your environment to production.

In my search to learn how to use Docker as a complete solution to develop with, I've found a range of tutorials which discuss or walk through some part of the process.

Sadly, no one tutorial contains all the steps necessary to step you through containerizing an (existing) application through to deploying said application in a production environment. Given that, my aim in writing this tutorial is to show you how to do this.

The challenge in doing so, unfortunately, is that there's a lot to learn and absorb. [...] So this is going to be a lengthy post. But I've aimed to provide the most direct path to your first production deployment, as well as to structure it so that it's easy to work through or navigate to the specific part you need.

He starts off with a few prerequisites you'll need to complete the process - a DigitalOcean account, a Docker Hub account, Docker installed and working and a project to deploy. The rest of the post is broken down into a few sections to make it a bit more consumable:

  • Create & Build the Container
  • Store the Image in an Accessible Registry
  • Build a Deployment Configuration
  • Make the Deployment

For each step in the process all of the code, configurations an commands you'll need are included. In some places screenshots are also included to help you ensure you're on the right path.

tagged: development deployment docker tutorial series production

Link: http://www.masterzendframework.com/docker-from-development-to-deployment/

Hackernoon.com:
Laravel in Docker
May 05, 2017 @ 12:13:32

On the Hackernoon.com site they've posted a tutorial showing you how to set up a Docker image of a Laravel application to help speed up your development using the framework and standardize the environment it lives in.

With this article you’ll learn how to prepare a Docker image of a Laravel application, push it to the registry, and use Docker in Continuous Delivery.

The post starts with a brief introduction of the two technologies at play, the Laravel framework and Docker, and what they provide. The tutorial then walks you through the entire process of setup, configuration and deployment of the Docker image:

  • Install Docker
  • Write a Dockerfile (including the install of Laravel)
  • Build Docker image (and Run)

At this point you have the image set up and ready to serve Laravel requests so they move on to sharing the image out on a Docker registry. In this case they opt to deploy it to hub.docker.com and use the login and push commands to quickly and easily share your creation. Finally they provide some use cases for this kind of deployment including creating standard development environments, using them for testing and keeping a consistent environment between development, staging and production.

tagged: laravel framework docker tutorial configure deploy dockerhub environment

Link: https://hackernoon.com/laravel-in-docker-ceed4465352

Adam Culp:
Easy Docker dev environments for PHP with CloudEstuary
Apr 17, 2017 @ 15:14:09

Adam Culp has written up a new post to his site showing you how to use the CloudEstuary service to easily create Docker development environments for your day to day work.

Lately I’ve been messing around with Docker, and specifically with containerizing PHP applications to perform quick services, such as static analysis of PHP code, compatibility of existing PHP code to specific versions of PHP, and performing security checks on PHP libraries included in my projects. However, I’ve not created a development environment for my projects using Docker.

[...] But today I found another way [besides using Vagrant]. A way to easily create PHP development environments with Docker. The fine folks at CloudEstuary have created an easy to use web-based tool to create PHP development environments (yml files) for use with Docker-compose.

He then walks you through the process of creating a new environment, selecting the framework to be installed by default and other "add-ons" to be include (it also allows for the addition of workers). After clicking on the "Generate Docker Compose" button the service spits out the YAML configuration file you can then use to create the environment. There's a few tweaks he recommends making to the config and, finally, the command to use the configuration and bring the environment up.

tagged: docker cloudestuary service compose tutorial configuration

Link: http://www.geekyboy.com/archives/1321

Rob Allen:
Using CircleCI for a PHP project
Apr 03, 2017 @ 09:56:20

In a post to his site Rob Allen shares a basic setup for using Circle CI with a PHP project for continuous integration. Circle CI provides the resources to build your project and perform tasks such as run unit tests or even deploy the resulting code to the production environment.

For a new client project, I've decided to use CircleCI to run my tests every time I push to GitHub. This turned out to be quite easy; this is how I did it.

He shares the contents of his .circleci/config.yml configuration file creating a Docker environment each time the build is executed, installing the required software, executing Composer install and running PHPCS and PHPUnit tests. He shares an example of the output from a build and how he hooked in Slack to receive notifications when the builds were complete (and pass/fail status).

tagged: circleci service continuous integration project tutorial configuration docker

Link: https://akrabat.com/using-circleci-for-a-php-project/

Stefan Koopmanschap:
Sculpin and Docker
Mar 22, 2017 @ 12:49:05

Stefan Koopmanschap has written up a tutorial on his site introducing the use of Docker and Sculpin to create an easily reproducible and manageable blogging setup.

I've been running this blog on Sculpin for quite a while now, and I'm quite happy with how that works. We've been in a process of migrating some of our websites off a standard VPS towards a setup with Docker, Gitlab CI and Rancher. I've now migrated some websites, which is relatively easy, but most of those sites were dynamic PHP websites. Migrating a site that generates static HTML and running that is a slightly different thing. Here's how I ended up doing it.

First he covers his old setup - essentially the manual run of a shell command to generate the latest version of a the static Sculpin site. He decided to update the process and help makes things more automatic using Docker and a Gitlab pipeline flow. He then documents his attempts and configuration options as he built up the Docker configuration he wanted. This ultimately resulted in a Docker setup that installed PHP and Nginx to serve up the site, Composer to load in the required dependencies (like Sculpin) and the commands to "deploy" the latest version of the site publicly.

tagged: sculpin docker setup configuration tutorial dockerfile php7

Link: https://leftontheweb.com/blog/2017/03/18/sculpin-and-docker/

Scotch.io:
Get Started Running Laravel in a Docker Container
Mar 07, 2017 @ 14:07:28

The Scotch.io blog has a new tutorial posted showing you how to get a Laravel application up and running in a Docker container with a minimal amount of work. The article assumes you already have a working knowledge of Laravel and Docker, so if you're not familiar with those you'll need to read up there first.

Laravel and Docker are two very popular tools of choice when considering building for the web. Although both of them do very different things, they can both be combined to create amazing products.

For our use case, we will be running Laravel in a Docker container. This is going to be a simple demonstration on how to use both products to create real-life applications. Nothing heavy.

The tutorial starts with some of the prerequisites you'll need before getting started but quickly gets into the commands you'll need to set up your environment. Using a custom Docker container they show you the configuration to get the container set up, how to build the database connection, bring the container up and verify all is working as expected.

tagged: docker laravel container tutorial introduction installation configuration

Link: https://scotch.io/tutorials/get-started-running-laravel-in-a-docker-container

Alejandro Celaya:
Run PHPUnit tests inside a docker container from PhpStorm
Feb 02, 2017 @ 11:14:04

Alejandro Celaya has a tutorial posted on his site showing you how you can improve your PHP workflow by running your unit tests in a Docker container from inside of PHPStorm.

Docker is, without any doubt, the trending tool these days. Everybody wants to use it, because it is very useful, allowing to easily generate development environments for any kind of application.

A couple months ago I started working with docker myself (it has taken me a while, I know), and now I can't imagine working without it. I started using it at work, but now I'm migrating all of my OSS projects too.

With Docker involved things get a bit more tricky when it comes to running your unit tests directly from PHPStorm (unlike local where it's just a few clicks away). Thankfully recent versions of PHPStorm come with a feature in the "Build, Execution, Deployment" that lets you define the location of the Docker executable. Then you'll need to set up a remote interpreter to link to the PHP binary then take that and link it back to the Docker installation. He ends the post showing how you can ensure it's working complete with a screenshot of the console showing the test results.

tagged: phpunit docker phpstorm container ide tutorial unittest

Link: https://blog.alejandrocelaya.com/2017/02/01/run-phpunit-tests-inside-docker-container-from-phpstorm/

James Cowie:
All hail Xdebug and lets let var dump die
Jan 12, 2017 @ 12:58:23

In a recent post to his site James Cowie sings the praises of Xdebug for debugging and says that "var_dump must die" as a method for debugging in your application development flow.

How many times have you been working in Magento or any other php application and hit an error, exception or something not quite right? For me a lot. I’ve been that developer that debugs by fire and throws echo var_dumps and dies around like a western gunslinger. It’s easy, provides quick feedback cycles but lets be honest its lazy, in efficient, rarely provides all of the data you need to solve the problem on the first try and its not something you want to boast about by the coffee machine.

[...] So whats the “better” way of debugging a application? Well welcome Xdebug + PHPStorm. Imagine inside of the IDE we can set a breakpoint, a fancy die and reload our web page. Magically the IDE has stopped execution and we can see the state of the application at that exact path. We can see the variables and we can step through the code and see exactly what class and method is called next and so on and so forth.

While his instructions are specific to PHPStorm, most major IDEs will have a similar setup process with their own tweaks. In his case, though, he has one more layer of complexity - the PHP is executing inside a Docker container. He walks you through the process he followed to get the flow from container to local IDE set up. He wraps up the post with an example of debugging a script and what the results look like inside of PHPStorm (including a screencast).

tagged: xdebug vardump phpstorm docker container tutorial

Link: http://jamescowie.me/blog/2016/12/all-hail-xdebug-and-lets-let-var-dump-die/

Mattias Noback:
Containerizing a static website with Docker, part III
Jan 09, 2017 @ 11:48:46

Matthias Noback has posted the third part of his "containerizing a static website with Docker" service, continuing on from his previous two posts to look at deploying the environment he's created.

In the previous posts we looked at creating a build container, and after that we created a blog container, serving our generated static website.

It's quite surprising to me how simple the current setup is — admittedly, it's a simple application too. It takes about 50 lines of configuration to get everything up and running.

The idea of the blog container, which has nginx as its main process, is to deploy it to a production server whenever we feel like it, in just "one click". There should be no need to configure a server to host our website, and it should not be necessary to build the application on the server too. This is in fact the promise, and the true power of Docker.

He then gets into the two remaining steps in the process resulting in the deployment of the simple application: pushing to Docker Hub and deploying out to a DigitalOcean server. He includes all of the commands and configuration you'll need to get the process set up and work with the remote machine.

tagged: docker series container part3 deploy dockerhub digitalocean

Link: https://php-and-symfony.matthiasnoback.nl/2017/01/containerizing-a-static-website-with-docker-part-iii/