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

Learnk8s.io Blog:
How to deploy Laravel to Kubernetes
Apr 30, 2018 @ 13:10:24

The Learnk8x.io blog has a tutorial they've posted showing you how to deploy a Laravel application to Kubernetes. Kubernetes is a system created to make it simpler to deploy containerized applications in a clustered context.

Vagrant is very good with setting up a local environment similar to a remote server. However, in production, you will most likely require more than just one web host and one database. You’ll probably have separate services for several requirements. You also need to have mechanisms in place to ensure that the application is always online and that the servers can efficiently balance the load.

In this article, I’ll explain how to deal with the simple requirement of running a Laravel application as a local Kubernetes set up.

The article then gets into the "whats" and "whys" of using Kubernetes and an introduction to the Minikube local Kubernetes environment. It runs through some of the prerequisites to getting the deployment set up and provides the Docker configuration to create and link the containers together. With that defined it provides the commands to get the environment up and running and the application deployed. The final part of the tutorial covers the scaling of the system and allowing ingress to the application through a certain URL.

tagged: kubernetes tutorial deploy laravel application docker container

Link: https://learnk8s.io/blog/deploying-laravel-to-kubernetes

Laravel News:
Running the Laravel Scheduler and Queue with Docker
Apr 25, 2018 @ 09:26:26

On the Laravel News site today there's a tutorial posted showing you how to combine Docker and Laravel's Scheduler/Queue and make them still run as they would on a virtual server.

In Laravel, one of the tricky changes when switching from a virtual server to Docker is figuring out how to run a scheduler and a queue worker. I see this question come up quite a bit when PHP developers are trying to figure out how to use Laravel with Docker.

Should you run them on the host server? Should you run via cron in a Docker container?

There are a couple of ways I recommend running the scheduler command and Laravel queues in Docker, and we’re going to cover the basics of running both with a complete (albeit simple) Docker setup you can use to experiment.

Their approach uses a single multi-purpose Docker image rather than splitting the functionality up and making it more complex (Laravel subscribes to the monolithic approach anyway). The post then gets into the setup of this environment using Docker and docker-compose to configure several services: application (app), a Redis container and a MySQL container. The contents of the docker-compose and Dockerfile configurations are included as well as the VirtualHost configuration for the main site. Next it shows the use of the CMD directive to run a bash script when the build is brought up. This is what kicks off the scheduler/queue handling. The post finishes up with a few other changes needed to the Docker configuration and the creation of the "scheduler" service.

tagged: laravel scheduler queue docker tutorial service execute bash

Link: https://laravel-news.com/laravel-scheduler-queue-docker

Robert Basic:
Docker containers for PHP with PHPDocker.io
Mar 28, 2018 @ 10:16:40

On his site Robert Basic covers a useful site for the PHP developers out there using (or wanting to use) Docker for their development. In this post he talks about the PHPDocker.io service that allows for the easy creation of a Dockerfile customized to the needs of your own environment.

Recently I’ve been also learning a bit more about PHPDocker.io.

He includes an example of the Docker configuration that's output from the service for a simple webserver+MySQL+PHP-FPM setup. He also includes a small update to allow the MySQL server to store its data on the local system rather than inside the container (where it would be lost on each build).

tagged: docker container phpdockerio service configuration tutorial

Link: https://robertbasic.com/blog/docker-containers-for-php-with-phpdocker-io/

Laravel News:
Install Microsoft SQL Drivers for PHP 7 in Docker
Jan 19, 2018 @ 12:51:05

The Laravel News site has a tutorial posted showing the Microsoft SQL Server users out there how to install the drivers and use it in a Laravel application in a Docker environment.

I started a project recently that required that I connect a Microsoft SQL Server database with a the final result when everything is up and running.

tagged: docker laravel microsoft sqlserver driver php7 tutorial

Link: https://laravel-news.com/install-microsoft-sql-drivers-php-7-docker

Symfony Finland:
PHP-PM 1.0 launches with Docker images and Symfony 3+ support
Jan 09, 2018 @ 09:37:01

As is mentioned in this post on the Symfony Finland site, the PHP-PM project has hit their first stable release, v1.0, that includes some nice tools as well.

Running an application server written in PHP has been feasible for some years. One of the robus mature options for this has been PHP-PM, a process manager. Now the project has reached a major milestone with the release of 1.0.

The PHP-PM team released the first stable release on 8th of January 2018. It builds on the work done for some years and it builds on ReactPHP. ReactPHP is a low-level library for event-driven programming in PHP.

PHP-PM allows creating long running PHP processes that serve applications directly instead of relying an embedded PHP (like with Apache's mod_php) or a web server with PHP process manager (as with Nginx and PHP-FPM).

Updates for this release include the addition of bridges for static handling, PSR-7 integration and version bumps for Symfony components used in the system. You can check out the full list of changes in the release notes if you want to see more. The post also links to other articles with more reading and tutorials covering PHP-PM and how to put it to use (including Docker integration and basic benchmarks).

tagged: phppm process manager stable version release docker image symfony update project

Link: https://symfony.fi/entry/php-pm-1-0-launches-with-official-docker-images

Colin O'Dell:
Installing PHP 7.2
Dec 01, 2017 @ 09:26:56

Right on the heels of the release of PHP 7.2.0, Colin O'Dell has posted a guide to installing it on several different operating systems.

type hints, saner count() behavior, and much more.

He then provides the commands you'll need to get your OS of choice updated (well, most of the popular ones at least):

  • Ubuntu 14.04, 16.04, 17.04, & 17.10
  • Debian 8 (Jessie) and 9 (Stretch)
  • Debian 7 (Wheezy)
  • CentOS / RHEL 6+ & Fedora 25+
  • Mac OS X
  • Windows
  • phpbrew
  • Docker

Each includes the command(s) you'll need to grab the package and perform the installation. If you need something more customized or your OS isn't listed, you can always compile from source too.

tagged: install php72 guide unix osx windows docker phpenv

Link: https://www.colinodell.com/blog/201711/installing-php-72

Youssouf El Azizi:
Laravel & Docker, Zero config with Vessel
Nov 28, 2017 @ 13:28:52

On the Hackernoon site Youssouf El Azizi has posted a quick tutorial showing you how to use Vessel with Docker and Laravel to create a "zero config" setup quickly and easily.

This article is a step-by-step to get started with Vessel ( the new way to setup the Laravel setup config with docker).

[...] Vessel is a lightweight docker environment for Laravel, that means it is just a small set of files that set up a local docker development environment per project and there is no extra thing to install globally, expect Docker system itself.

The tutorial then walks you through the process you'll need to follow to get the environment up and running including the installation of Docker/Docker-compose. It then walks through the installation of Vessel and what images (containers) it will set up when executed. The post ends with a "cheat sheet" you can use when working with Vessel providing some common commands.

tagged: tutorial laravel docker configuration setup vessel container

Link: https://hackernoon.com/laravel-docker-zero-config-with-vessel-60e1aa173ea8

Master Zend Framework:
What Does It Take To Start Using Zend Expressive?
Nov 20, 2017 @ 11:23:17

On the Master Zend Framework site Matthew Setter has posted a new tutorial showing you what it takes to get started using Zend Expressive. The article is more about the environment the framework would live in (well, the application written with it) than the actual framework itself.

Ever thought that it's hard to get started with Zend Expressive? Ever think you need to know Vagrant, Ansible, Docker, Puppet, Linux, and more? Nope, you don't! In this post, I'm going to show you that, while these tools can help, if you’re just getting started with the framework (such as learning about it), you don't need them.

I want to be clear, before we go any further, that I’m not talking about doing fully-fledged development. [...] So what I’m talking about here is when you’re just starting out and getting a feel for Zend Expressive, right up to building a test application. I’m not talking about a fully-fledged, deployed application that requires copious tests, one backed by a CI/CD pipeline.

He then talks a bit about the history of Zend Framework and how one of Expressive's goals it to help take some of the sting out of using it. Following this he covers some of the possible tooling you could use including two environment tools: Docker (useful but not required) and Vagrant (handy but also not a must). Finally he gets to the actual requirement - a version of PHP 7 installed on the system. He shows how it, along with its included web server, can be used in development to host an Expressive site by itself.

tagged: zendexpressive zendframework tool environment tutorial docker vagrant

Link: https://www.masterzendframework.com/what-does-it-take-to-get-started-with-zend-expressive/

Symfony Finland:
Running Symfony without a web server on Docker using PHP-PM
Oct 25, 2017 @ 10:30:05

On the Symfony Finland site there's a tutorial posted showing you how to run Symfony without a web server using Docker and PHP-PM.

Docker containers have been becoming an increasingly common deployment method in the past few years. I've deployed some Node.js app in containers, which are very simple to deploy as there's a single process that's easy to run. I found running PHP to be more complex.

[...] When running Nginx and PHP-FPM you are forced to run a pair of of containers, one for PHP-FPM and one for PHP-NPM. [...] But I would rather just run a single process to run the application. This is how Go, Node.js and even .NET Core apps are deployed. Can PHP do without a middle man?

While it may not be the most performant way to run a PHP and Symfony application, the author wanted to try it out and see how difficult it might be. The code for the setup is provided and, while the end result was a bit difficult to get to, it was possible.

tagged: symfony finland webserver without docker phppm tutorial code

Link: https://symfony.fi/entry/running-symfony-without-a-web-server-on-docker-using-php-pm

Asmir Mustafic:
How do I deploy my Symfony API - Part 4 - Deploy
Oct 11, 2017 @ 10:23:12

Asmir Mustafic has posted the next part of his series covering the deployment of Symfony applications. In this latest article (part four) he focuses on some of the final steps of the deployment process.

This is the forth post from a series of posts that will describe the whole deploy process from development to production. The first article is available here, the second here and the third here.

After covering the steps 1-3 and having prepared our infrastructure, we can see how to deploy our application to production. Almost the same approach can be used to deploy not only to production but also to test environments.

He starts with the workflow for the deployment process, creating a flow where the "git push" should trigger other actions based on the branch pushed. Then CircleCI will fire off a series of jobs to handle environment setup tasks, connecting to a VPN and deploying the code. This includes a bit of preparation, credential handling and the Docker setup and push. Each step along the way also includes all of the YAML configurations you might need to replicate the deployment.

tagged: symfony api deployment part4 series docker configuration example

Link: https://www.goetas.com/blog/how-do-i-deploy-my-symfony-api-part-4-deploy/