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

Delicious Brains Blog:
Behind-the-Scenes: How We’re Automating Acceptance Testing
Aug 15, 2017 @ 10:57:04

On the Delicious Brains site Ian has written up a lengthy post sharing how they automate their acceptance testing for their PHP applications.

Have you ever had the joy of carrying out acceptance tests? For our team at Delicious Brains, testing our releases, in the past, has been one of the most dreaded tasks on the to-do list. We hold our plugins to a high quality standard so it’s a must but manual tests are brain-numbingly tedious and can take hours of expensive developer time.

Recently, we decided it was high-time to fix that. [...] Read on for more about how the automation of testing our plugins ahead of release is shaping up – including how we manually tested in the past and a look at some of the automated acceptance tests we’ve already implemented.

He starts by defining what acceptance testing is and how they're different from other types of testing. He then shows the manual method they were using to run their tests previously and what prompted the move towards automation. He talks about the tools that they use for their automated testing including Codeception and Docker. Configurations and scripts are included that make the automation work and some of the issues they came across during the move from manual to automated processes.

tagged: automated testing codeception docker tutorial setup configuration manual

Link: https://deliciousbrains.com/how-were-automating-acceptance-testing/

Delicious Brains Blog:
How to Use Xdebug for Advanced PHP Debugging
Aug 07, 2017 @ 10:17:14

On the Delicious Brains site there's a tutorial posted that shows you how to use XDebug for advanced PHP debugging versus some of the usual practices of var_dump or print_r-ing your way through your testing.

You could just debug your PHP code using functions such as error_log, print, and var_dump, (and to be honest we’ve all done it, a lot!), but sometimes they just aren’t enough, and can actually slow you down while developing.

There must be a better way, surely?! Enter Xdebug, the rather awesome debugging and profiling tool for PHP.

In this post, I’ll take you through why Xdebug is amazing, getting it setup, how to use it, get the most out of it it, and some neat advanced uses all to make your life easier.

He starts with some background on his previous debugging practices and how discovering XDebug revolutionized his workflow. He then talks about breakpoints for debugging and what he calls "debug driven development". The article then walks you through the installation process and the integration with IDEs, specifically PHPStorm. The rest of the post shows examples of how to use XDebug along with breakpoints and IDE features to get more information about the current application state and where things are failing. He also includes sections about using XDebug for profiling and performing remote debugging via an SSH tunnel.

tagged: xdebug introduction debugging profiling tutorial setup ide integration

Link: https://deliciousbrains.com/xdebug-advanced-php-debugging/

Laravel News:
Homeboy Allows You to Automate Adding Sites to Homestead
Jul 10, 2017 @ 09:27:32

On the Laravel News site there's a quick post highlighting a tool that can be use to help automate adding sites to your local Homestead environment - Homeboy.

Homeboy is a new package for Laravel Homestead that allows you to add a new local development site quickly. Once you run the command line tool, it will update your host file to point your dev domain, update your Homestead.yaml file to include mapping to for the new project and create a database mapping, and finally, it’ll re-provision Vagrant.

The post also includes a screencast the project has shared showing the tool in use (though the choice of soundtrack is questionable). It basically works as a shortcut to adding the changes to the files yourself, making it simpler to spin up new sites and environments quickly.

tagged: homeboy laravel homestead environment setup configure tool

Link: https://laravel-news.com/homeboy-allows-you-to-automate-adding-sites-to-homestead

Exakat Blog:
Up and running exakat in 15 mins
Jun 01, 2017 @ 11:32:41

On the Eakat blog they've written up a post showing you how to get the scanner up and running quickly on your system and start performing scans of the code based on their ruleset.

Exakat is a smart static analysis engine for PHP. It reviews the code fast and produces reports tailored for every needs : issues and code smell for programmers, inventories and maps for architect ; compilation and configurations lists for sys admins ; dashboards for team leaders. Including over 320 analysis and spanning versions from 5.2 to currently WIP 7.2, it helps you audit your code and keep it under control. Let’s see how to get up and running exakat in 15 mins.

The post then walks you through the installation process and defines some prerequisites you'll need before getting started. The Exakat installation is basically just grabbing a phar archive from the exakat.io server. Once it's installed they show you how to run your first scans and view the resulting output. The guide also shows you how to add additional options to the reporting and the command to update Exakat itself.

tagged: exakat scanner tool setup configuration quickstart tutorial

Link: https://www.exakat.io/up-and-running-with-exakat/

Hackernoon.com:
How to configure PHPStorm to use PHP-CS-Fixer
Apr 25, 2017 @ 10:47:46

On the Hackernoon site there's a recent tutorial showing you how to hook the PHP-CS-Fixer tool into PhpStorm for easy execution during development rather than after.

The PHPStorm IDE by JetBrains is probably one of my favorite editors. It has its flaws (constant indexing…) but overall its a great tool for me. However, my focus today is not on PHPStorm per say but rather how to add the awesome functionality of using project page. Depending on your platform you will need to make some decisions, namely how you configure the rules of PHP-CS-Fixer. I am currently on Windows but I will try to make sure these instructions work in both *nix and Windows environments.

He then walks you through some prerequisites (both pieces of software installed basically) and the decisions to make based on your platform. He then provides screenshots and descriptions showing where to go in the PhpStorm IDE to add the PHP-CS-Fixer as a new "Tool", the working directory to use and how to set up a keymap to execute the tool. He includes an example of the output when things are correctly configured and working together.

tagged: configure phpstorm phpcs phpcsfixer tool tutorial install combine setup ide

Link: https://hackernoon.com/how-to-configure-phpstorm-to-use-php-cs-fixer-1844991e521f

SitePoint PHP Blog:
How Can I Use Laravel Envoyer or Deployer with SemaphoreCI?
Apr 04, 2017 @ 11:16:59

The SitePoint PHP blog has posted a tutorial showing you how to use Laravel Envoyer or Deployer with SemaphoreCI and popular continuous integration service.

Test automation, continuous integration, and continuous delivery are quite widespread in the community now. This brought to life multiple services trying to make the process more enjoyable and less overwhelming for developers, so they can focus on delivering software instead of building/configuring tools to do that. One of those services is SemaphoreCI.

In this article, we’re going to cover how to use our own deploy scripts and tools to continue the deployment process after a successful test.

They then show you how to create the Deployer configuration file to make the deployment to the remote Digital Ocean servers of a Laravel-based application. Most of the steps are in copying the local files up to the remote server as a "staging" environment. He then hops back over to the SemaphoreCI service to create the deployment plan for the project using the "deployer.phar" command line tool, linking it to the push of new code. They then move to the same process just defined via the Laravel Envoyer tool and a similar command line call.

tagged: laravel envoyer deployer semaphoreci tutorial setup configure plan

Link: https://www.sitepoint.com/how-can-i-use-laravel-envoyer-or-deployer-with-semaphoreci/

Robert Basic:
PHP traits to create test doubles
Apr 04, 2017 @ 10:47:15

In a new post to his site Robert Basic shows how to make use of traits to create test doubles in your unit testing practice. He sees them as a simple method for keeping tests clean and not having mocks/fakes/etc. all over.

Keeping your application or library code well organized, easy to follow, and read is important. Your test code should not be exempt from those rules, you should follow good testing conventions.

One part of my tests that I feel like that are out of control are the test doubles. Dummies, fakes, mocks… Seems like they are everywhere and that I keep writing the same ones over and over again. I do follow some good practices on how to reduce code duplication in my tests, but these mocks… Ugh.

He starts with a simple example, showing a test that evaluates the result of a transaction being executed (true or false). However, he describes the eventual "creep" of the tests as more are added and, with each, more "transaction" object instances are required. He suggests refactoring the creation of those doubles into traits where the class they're called from can inherit them and test setup is a bit cleaner. He proposes a "trait for every double" so that they can be easily included as needed and without conflict.

tagged: traits unittest double mock tutorial example setup object

Link: https://robertbasic.com/blog/php-traits-to-create-test-doubles/

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/

SitePoint PHP Blog:
Crash Course: Continuous Deployment with Semaphore CI
Mar 13, 2017 @ 12:42:23

On the SitePoint PHP blog there's a new post that gives you a crash course in using Semaphore, a "continuous delivery pipeline" service, and how to use it to deploy your PHP applications.

Understanding continuous delivery, a now already long-standing buzzword, is not a problem, but implementing it in the right way has been a challenge for quite a few of us, and one we’ll discuss in this post.

[...] In this article, we will cover the process of deploying a Laravel application on a Digital Ocean server through a continuous delivery pipeline using Semaphore. The source code for the application is present on Github.

They walk you through each step of the way (complete with screenshots) to:

  • Create a Semaphore account, linking it to GitHub
  • Creating a new Project
  • Setting up the plan for the deployment
  • Performing the first build
  • Parallelizing the builds

With the project all set up the tutorial then starts on the continuous deployment changes, adding in a "Deployment" step and making a first push.

tagged: crashcourse continuous deployment semaphoreci tutorial setup configuration

Link: https://www.sitepoint.com/crash-course-continuous-deployment-semaphore-ci/

Laravel News:
Laravel Forge API
Feb 28, 2017 @ 14:36:37

The Laravel News site has posted an official announcement about the Forge API being released for public use. Forge is a service that makes it easier to set up and configuration servers by taking care of a lot of the details for you.

Laravel Forge just announced it’s first official API that allows you to create and interact with your servers and sites.

This was a highly requested feature and the API includes support for all the features Forge provides including Servers, Services, Daemons, Firewall Rules, Sites, SSL, and more.

The post includes how to get started with the API, where to get your API token and how to send it over for authorization handling. You can find more information about the Forge API in the documentation on the Forge site.

tagged: laravel forge api release announcement server setup configure

Link: https://laravel-news.com/laravel-forge-api