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

Deployer Blog:
How to deploy Laravel application
Nov 22, 2016 @ 12:39:30

In a new post to their blog the Deployer project (a PHP-based deployment tool) has shared a quick tutorial about deploying Laravel applications using the tool and just a few simple commands.

Apparently you already have some Laravel application and some server or shared hosting. Now you need to automate the process of deployment. Deployer will helps you in this as it ships with some ready to use recipes for Laravel based application.

They start with the details about installing the tool then share the single "dep init" command to create the deployment configuration needed to deploy a default Laravel application. There's a few modifications you'll need to make for your own project (like repository location, server information and the path to your SSH key) but that's basically it. The "dep deploy" command can then be used to push the release to the remote server in a "current" directly ready and waiting for your web server to serve up.

tagged: deployer deployment tool tutorial laravel application setup

Link: https://deployer.org/blog/how-to-deploy-laravel

SitePoint PHP Blog:
Hashicorp’s Packer – Is It Something for PHP Developers?
Nov 15, 2016 @ 11:38:24

The SitePoint PHP blog has a new article posted taking a look at Packer (from Hashicorp) and if it's something that's relevant to a PHP developer's needs. Packer is a tool that makes it easier to machine images that can be reused across platforms based on a single configuration.

If you do a lot of server work for your clients or on the job, along with development work, then yes. Packer can help you a lot.

If you are only a developer and don’t really do much work on the server directly, then no. Packer won’t be very helpful.

That being said, it is wise for any PHP developer to learn the basics of creating server environments. You will run into these technologies in your career in one way or another (everything you create runs on them!). This specialized knowledge will help your career in the future for sure! At a minimum, you’ll understand your dev-ops colleagues and the work they do much better.

The article starts with a "look back in time" to when server setup was more manual and server admins/developers had to go in and change configurations/update software by hand. From there they move forward to the changes that virtualized servers made possible followed quickly by tools like Vagrant. Vagrant makes it easier to create and configure virtual machines so why would you need something like Packer? The article provides a summary of the features that Packer provides and how its overall workflow operates.

With all this information under your belt, the tutorial then starts in on using the Packer tool:

  • installing the Packer software
  • creating a new server instance
  • setting up the JSON configuration
  • the build process
  • working with provisioners
  • installing the VM with VirtualBox

The environment is now all set up and configured so the next step is, naturally, installing a PHP-based application. They opt for a basic Symfony demo application, showing how to change the configuration to pull it in and set everything up.

tagged: hashicorp developer packer tutorial configuration vagrant server setup

Link: https://www.sitepoint.com/hashicorps-packer-is-it-something-for-php-developers/

TutsPlus.com:
Building Your Startup: Preparing for Reminders
Nov 14, 2016 @ 11:57:06

The TutsPlus.com site has published the latest tutorial in their "Building Your Startup" series that walks you through the creation of an application (a meeting planner) using the Yii2 framework. In this latest post they start on the reminders integration used to notify attendees of upcoming meetings.

his tutorial is part of the Building Your Startup With PHP series on Envato Tuts+. In this series, I'm guiding you through launching a startup from concept to reality using my Meeting Planner app as a real-life example. Every step along the way, I'll release the Meeting Planner code as open-source examples you can learn from. I'll also address startup-related business issues as they arise.

In this two-part series, I'll describe how we built the infrastructure for reminders and their delivery. This episode will focus on the infrastructure and user experience behind configuring reminders.

They start off by talking about the goals for the reminders and how they'll integrate with the current Meeting Planner system. With that settled the article shows you how to:

  • set up the "reminders" table in the database
  • set up reminders for new and existing users
  • linking them to meetings
  • adding code to handle the creation of new reminders

This is all setting the application up for the next part in the series where they'll use this structure (and some additional functionality) to allow users to create the reminders via the UI.

tagged: startup series meeting planner reminders setup database tutorial

Link: https://code.tutsplus.com/tutorials/building-your-startup-preparing-for-reminders--cms-26527

Adam Wathan:
Replacing Mocks with Spies
Oct 13, 2016 @ 10:25:14

In this post to his site Adam Wathan shares a unit testing tip that can help you with more correct verification in your testing - replacing mocks with spies.

Mock objects are useful when verifying that a method was called is more important than verifying the outcome of calling that method.

[...] Mocks are a great tool, but it’s always bugged me that they force you to set expectations in advance instead of making assertions at the end like you would in a traditional test.

He gives a Laravel-based example of using Mockery to set an "expects" call on a method to ensure it's correctly called. He points out, however, that this method is more useful for checking the result of the method call and not really the fact that it was called (a slight but interesting difference). He then gives an example of testing the PHP function strrev and the phases you would go through in the testing process. He suggests that, in the creation of the mock object, you're mixing up the "setup" phase with the "assertion" phase and making them dependencies. He shows how, with a switch over to using spies instead, including the code updates for Mockery that change the mock object creation and split out the assertion from the creation.

tagged: mock spy unittest mockery assertion setup

Link: https://adamwathan.me/2016/10/12/replacing-mocks-with-spies/

Theo Tzaferis:
Let CodeSniffer inspect your code in PhpStorm
Sep 15, 2016 @ 10:56:32

In a quick new post to his site Theo Tzaferis shows you how to set up PHPStorm and PHP_CodeSniffer to perform automatic inspection of your PHP code's syntax.

Some time ago I wrote an article on how to format your code automatically in PhpStorm to be conform the PSR standards. In this article I want to show you how you can enable inspections in PhpStorm which throws a warning if you have code which is not PSR, e.g.
  • Whitespace at the end of line
  • No newline at the end of file
  • No newline between namespace and use statements
  • etc…
This is pretty easy. We will use squizlabs/PHP_CodeSniffer from Github.

I’m doing this on an Ubuntu machine, but it should work the same in OS X (no idea about Windows).

He then provides the (*nix-centric) instructions on getting the two tools up and playing happily together. Fortunately PHPStorm comes with handy built-in support for PHP_CodeSniffer, basically only requiring you to install phpcs and point it to the right location. The rest is handled by the IDE when you enable the automatic evaluation.

tagged: phpstorm codesniffer tutorial setup configure automatic inspection

Link: http://tzfrs.de/2016/09/let-codesniffer-inspect-your-code-in-phpstorm/

SitePoint PHP Blog:
Local Composer for Everyone! A Conference-Friendly Satis Setup
Aug 30, 2016 @ 11:13:30

On the SitePoint PHP blog editor Bruno Skvorc has posted a tutorial showing you how to set up the Packagist alternative, Satis, in a local network configuration instead of requiring users to still access the external web.

While preparing my technical materials for WebSummerCamp, I realized my workshop would rely on a fairly stable internet connection, as we’d have a lot of ground to cover and a lot of packages to install. Rather than rely on the gods of live demos, or pre-installing everything and ruining the experience, I picked another route.

In this post, I’ll show you how to set up a local Satis instance and have it host the packages over the network it’s currently on, so that everyone who’s also connected to it can put the address into composer.json as a custom repository source, and retrieve all packages from your machine locally – no internet connection required!

He then shows you how to set up the system on a Homestead Improved VM locally, cloning Satis inside of it. He includes an example of the configuration of his required packages and how to build the local repository using this setup. Then, using the built-in PHP web server, he shows the result of the setup and how to access it from other machines. Finally, a few updates are required to the user's composer.json to use the local versions instead of the normal remote connection for the package downloads.

tagged: composer satis local network tutorial setup configuration example

Link: https://www.sitepoint.com/local-composer-for-everyone-a-conference-friendly-satis-setup/

SitePoint PHP Blog:
Up and Running with the Fastest PHP Framework on PHP7 in 5 Mins
Aug 24, 2016 @ 11:22:46

On the SitePoint PHP blog editor Bruno Skvorc has posted a tutorial helping you get up and running with PHP 7 and Phalcon in five minutes on a Homestead Improved virtual machine.

You may remember our past infatuation with Phalcon, the fastest PHP framework.

In this post, we’ll go through the process of getting it up and running in 5 minutes on one of our <a href="http://www.sitepoint.com/quick-tip-get-homestead-vagrant-vm-running/>Homestead Improved instances. If you’re not interested in why or what Phalcon is, just skip ahead to “Setting it up”.

He starts with a brief recap of what the Phalcon framework is (including Zephir), some history behind it and the latest advancement around the framework: LTS support for v3.0. The tutorial then gets into the setup and configuration of the VM along with PHP 7 and the latest stable version of Phalcon. He then uses the sample application provided by Phalcon and getting it boostrapped and running.

tagged: phalcon php7 tutorial demo homesteadimproved vm setup configure extension

Link: https://www.sitepoint.com/up-and-running-with-the-fastest-php-framework-on-php7-in-5-mins/

Symfony Finland:
Consider Docker for your Symfony projects
Aug 15, 2016 @ 11:24:35

On the Symfony Finland site there's a post that makes a recommendation for your Symfony framework based projects: give Docker a try to make setup and maintenance simpler.

During the first half of 2016 the web development community has talked about Docker quite a bit. The technology has been around since 2013, but during the last few months it has matured and started being adopted for mainstream web development. Docker is a great fit for Symfony projects too.

[...] Docker takes an approach where it wraps a piece of software into something known as a container. These containers are shipped complete with the application code, a runtime, system tools and libraries. Containers are thus guaranteed to always run the same, but can share files and networking with the host and other containers.

They then talk about how this "containerized" setup can be used to your advantage, making it simpler to get a Symfony application up and running with a few commands. The post then gets into an example setup of a Symfony Docker environment complete with Nginx, Varnish and PHP-FPM installed and linked. There's also setup for MySQL and Redis rounding out the data storage side. A quick "docker-composer up" command and, if all goes as expected, the environment is set up and waiting for your application.

tagged: symfony finland docker project tutorial setup configure

Link: https://www.symfony.fi/entry/consider-docker-for-your-symfony-projects

Chris Tankersley:
My Docker Setup
Jul 29, 2016 @ 11:56:11

Docker has quickly become one of the tools that have helped make difficult environment setup and thing of the past. Chris Tankersley, a PHP developer and devops practitioner, has shared some about his own PHP Docker workflow in a new post to his site.

When it comes to Docker, I use Docker Compose to set up and link all of my containers together. It's rare that I have a single container, though many of my Sculpin-based sites live quite comfortably inside of an nginx container, but even those take advantage of volumes.

For his standard three-tier setup he defines a basic docker-compose.yml configuration file with required services (nginx, PHP server, MySQL and Composer), local volume information and the links between them. With that working he uses another script to set up some PHP extensions and Composer as a service (making it a service provides isolation). He also includes the scripts he's written up to help run a few extra commands and execute the Composer and PHP commands much easier. He wraps the post up talking about how all of this fits into his overall workflow and how it relates to the deployment of the application into other environments.

tagged: setup environment workflow setup docker configuration deployment

Link: http://ctankersley.com/2016/07/27/my-php-docker-workflow/

Chris Tankersley:
My Docker Setup
Jul 29, 2016 @ 11:56:11

Docker has quickly become one of the tools that have helped make difficult environment setup and thing of the past. Chris Tankersley, a PHP developer and devops practitioner, has shared some about his own PHP Docker workflow in a new post to his site.

When it comes to Docker, I use Docker Compose to set up and link all of my containers together. It's rare that I have a single container, though many of my Sculpin-based sites live quite comfortably inside of an nginx container, but even those take advantage of volumes.

For his standard three-tier setup he defines a basic docker-compose.yml configuration file with required services (nginx, PHP server, MySQL and Composer), local volume information and the links between them. With that working he uses another script to set up some PHP extensions and Composer as a service (making it a service provides isolation). He also includes the scripts he's written up to help run a few extra commands and execute the Composer and PHP commands much easier. He wraps the post up talking about how all of this fits into his overall workflow and how it relates to the deployment of the application into other environments.

tagged: setup environment workflow setup docker configuration deployment

Link: http://ctankersley.com/2016/07/27/my-php-docker-workflow/