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

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/

TJ Miller:
Separate Interactive Test Suites
Mar 26, 2018 @ 12:56:24

In a post to his Medium.com site TJ Miller has a quick post for the PHPUnit users out there showing how to isolate your tests and prevent them from interacting by splitting them into different test suites.

On a recent Full Stack Radio episode Adam Wathan and Taylor Otwell were talking about testing Laravel applications. During the episode, they spoke about isolating interactive integration tests from your normal testing e.g. payment gateways, third-party integrations.

TJ shares an example of a project he's working on where this is useful: avoiding interactions with an HTTP API every time the tests run. He then shows how, with a single PHPUnit configuration, you can split up the tests by name and directory to prevent them all from executing every time. Then the "testsuite" option can be used to isolate the execution from the command-line. An example of the XML configuration is also included in the post.

tagged: tutorial phpunit separate test suite isolation configuration

Link: https://medium.com/@sixlive/separate-interactive-test-suites-f6fd59316ec2

Dries Vints:
Laravel Horizon with Forge and Envoyer
Feb 15, 2018 @ 10:53:16

Dries Vints has posted a step-by-step guide for the Laravel users out there showing how to set up Laravel Horizon using Forge and Envoyer for the server management. Laravel Horizon is a frontend/backend interface for Laravel that makes working with Redis easier.

I recently installed Horizon for Laravel.io and while it wasn’t that hard to install, I still had to figure some things out. Since this was the first time setting everything up I thought I’d write up the steps to take to get started with Horizon and set everything up with Forge and Envoyer.

[...] Remember that this isn’t a guide that dives deep into Horizon, just enough to get it up and running. If you want more info about Horizon’s internals I suggest this excellent post by Mohamed Said.

The tutorial then walks through the six step process to get the full deployment flow set up:

  • Step 1: Installation
  • Step 2: Configuration
  • Step 3: Scheduler
  • Step 4: Authentication
  • Step 5: Envoyer
  • Step 6: Forge

When the setup and configuration is complete the deployment you'll end up with a Horizon environment ready to use. The post ends with a reminder for queue management and where to change the setting to be applied in the next deploy.

tagged: laravel horizon forge envoyer deployment setup configuration tutorial

Link: https://medium.com/@driesvints/laravel-horizon-with-forge-and-envoyer-82a7e819d69f

Barry van Veen:
Package development: run a package from a local directory
Jan 31, 2018 @ 09:22:03

Barry van Veen has a quick post on his site showing the Composer users out there how they can use a package from a local directory without having to go through the hassle of pushing it and adding it to Packagist.

Suppose you run a website and want to split part of it into a package with its own repository. You start a new repository and check it out on your development machine. But now you want to see how the website and your new package integrate. How to go about this?

This article explains how you can require a package from a local path into your project with Composer. This way you can run a local copy of a repository and test any changes you make. Because the local repo will be symlinked changes are shared in real-time, there is no need for intermediate committing and updating.

He shows how to update your composer.json configuration's repositories section to add an entry with a "type" value of "path". This then points to the location on the filesystem where the package resides. Then it's just a matter of requiring the dev-develop branch and the code will be treated just like any other package. He also includes a section showing how to handle things when symlinking fails, a problem that usually happens on Windows for VM users. Usually it's related to a permissions error for whatever user is running the VM.

tagged: package local path composer configuration symlink repository devdevelop

Link: https://barryvanveen.nl/blog/44-package-development-run-a-package-from-a-local-directory

Martin Hujer:
17 Tips for Using Composer Efficiently
Jan 05, 2018 @ 09:25:31

Martin Hujer has written up a guide for the Composer users out there (you do use Composer, right?) sharing seventeen tips for using it effectively to manage the dependencies in your applications.

Although most PHP developers know how to use Composer, not all of them are using it efficiently or in a best possible way. So I decided to summarize things which are important for my everyday workflow.

The philosophy of most of the tips is "Play it safe", which means that if there are more ways how to handle something, I would use the approach which is least error-prone.

His tips include:

  • Be aware of differences between a "project" and a "library"
  • Use version ranges for libraries dependencies
  • Run Travis CI builds with different versions of dependencies
  • Do not attempt to merge composer.lock when rebasing or merging
  • Update dependencies safely
  • You can define other types of dependencies in composer.json

Each item in the list comes with a summary and an example of the configuration related to the tip. Most of them are small tweaks to the configuration you're probably already using but there are definitely some nice "hidden gems" in there.

tagged: composer tips effective top17 configuration dependency

Link: https://blog.martinhujer.cz/17-tips-for-using-composer-efficiently/

Pineco.de:
Hosting Private Laravel Packages on GitLab
Dec 19, 2017 @ 12:58:27

On the Pine site they've posted a quick tutorial showing how to host private packages on Gitlab, in their case it's for Laravel-related packages but it would work with any project making use of Composer for package management.

When we want to restrict the access to the package we made but we don’t want to pay for a service like Private Packagist, we can use tagged: hosting gitlab private package accesstoken tutorial composer configuration

Link: https://pineco.de/hosting-private-laravel-packages-gitlab/

Caleb Porzio:
My VS Code Setup
Dec 14, 2017 @ 09:53:50

Caleb Porzio has put together a post for those out there either considering using Microsoft's Visual Code Studio IDE or just want to see what it would be like for PHP development. In his post he shares his setup since making the switch over to the IDE full time.

I’m using VS Code as my primary editor these days and am really digging it. My setup is by no means perfect, but I've made lots of little tweaks along the way that you may benefit from.

I've set up these nifty categories, so feel free to jump around and try stuff out as you go, or come back later and use it as a reference.

Categories in the post include useful extensions, "must-have" settings, changing up the look and useful keybindings. There's plenty of links, output examples, screenshots of the IDE and the configuration options you'll need to change to update the settings to match his.

tagged: visualstudiocode vscode ide setup configuration extension setting

Link: http://calebporzio.com/my-vs-code-setup-2/

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

Rob Allen:
Customising Whoops in Expressive
Nov 08, 2017 @ 09:53:40

Rob Allen has a new post to his site showing how you can customize the Whoops output in a Zend Expressive application. Whoops is a package that provides more well-structured and more attractive error output when an issue comes up.

I find the Whoops error handler page in Expressive quite hard to read and particularly dislike that the error message displayed in the top left is hidden if it's more than a few words long.

To fix this, I discovered that you can provide a custom CSS file to the PrettyPrintHandler and then override to your heart's content! One way to do this is to add a delegator factory to add the additional functionality, so let's do that.

He then includes the configuration changes you'll need to make in the Expressive setup to have it recognize the factory and be able to use it as a dependency. He then includes the code to create the factory itself, adding a path to the local CSS files and pushing the custom whoops.css file into the page handler. Example CSS is included showing an update to the display of the main message, removing the need for a mouseover to view it.

tagged: zendexpressive zendframework whoops error handler css configuration factory tutorial

Link: https://akrabat.com/customising-whoops-in-expressive/

Joshua Thijssen:
Symfony's autowiring
Nov 02, 2017 @ 10:26:18

Joshua Thijssen has a new post to his site looking "under the hood" at Symfony's autowiring functionality used to locate and initialize services for the framework as needed.

When asking people if they use Symfony’s autowiring functionality, an often heard excuse why people don’t use it is because of all the magic that is happening during autowiring. But just like most impressive magic tricks, once explained, it all boils down to a few simple principles and Symfony’s autowiring is nothing different in that perspective. In this blogpost I will explain the new autowiring and autoconfiguration features, and why you should love them.

He starts off with an example of how to define services manually. He then explains how these services are used in the code and how to pass in arguments when fetching. He then moves on to the automatic generation of the services (the autowiring) and how the framework is "tricked" into using the namespace of the discovered service as the name. This is also used in dependency handling. The post then covers when the autowiring won't work, autoconfiguration and how to set defaults on service definitions (for arguments).

tagged: symfony autowiring tutorial indepth configuration framework

Link: https://adayinthelifeof.nl/2017/09/19/symfony-autowire.html