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

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/

Nikola Posa:
Keep PhpStorm metadata away from project sources
Mar 15, 2017 @ 11:54:57

In a new post to his site Nikola Posa shows the PHPStorm users out there how to keep metadata about your projects away from the source (the content in the ./idea directory it creates by default).

I fell in love with PhpStorm only few months ago ago when I switched from NetBeans, my favorite IDE by then. One thing that I was missing from the very start is the ability to separate project metadata (.idea/ directory) from sources, because I like to keep away everything that is unnecessary from my project directory, as well as from the .gitignore file. It turned out that something like that is possible, but in contrast to NetBeans it's not so evident and requires a little more effort

It's a pretty simple four step process and he shows what settings to change:

  • Create new project in a directory where you would usually keep metadata
  • Open Settings / Preferences dialog and click on Directories node
  • Click Add Content Root button and select project sources directory
  • Remove content root that keeps project metadata

Screenshots are also included for each step to help make sure you're in the right place at all times.

tagged: phpstorm metadata project source setting configuration

Link: http://blog.nikolaposa.in.rs/2017/03/09/phpstorm-metadata-away-from-project-sources/

SitePoint PHP Blog:
The Android Elephpant - Laravel on your Android Phone?
Mar 14, 2017 @ 13:06:05

On the SitePoint PHP blog there's a new tutorial posted with an interesting idea for the use of PHP - running it on an Android phone (a Laravel application specifically).

It was not that long ago that Christopher Pitt wrote an excellent article about writing and running PHP code on an iPad. After reading it, I thought to myself "It would be really cool to do the same on Android": being able to write and edit code on the fly, for example while traveling, and not having to take the laptop everywhere. So I’ve decided to do some research and see what I could come up with.

For this article, you can use any type of Android device. I’ve done it on my phone, but an Android tablet with a Bluetooth keyboard would probably be the ideal setup.

Using the Termux application and using it to install various packages for both development and PHP usage. They also install Vim, Git and Composer to make package management easier. Once the environment is installed it moves on to the Laravel installation (that works just fine), installing SQLite for the database and building out the user authentication and authorization handling with Laravel's "make:auth" artisan command.

tagged: android tutorial phone laravel install configuration

Link: https://www.sitepoint.com/android-elephpant-laravel-android-phone/

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/

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

Creating a custom queue driver for Laravel
Feb 09, 2017 @ 19:21:04

On the DotDev.co blog there's a new post showing you how to create a custom queue driver for Laravel allowing you to define the logic and handling for background job processing with the framework.

Ever needed to use a queue service not supported by Laravel? No, me neither! However, recently I needed to tweak the config for the SQS driver in order to utilise a couple of the Amazon configuration settings. Unfortunately, these settings are not natively exposed by Laravel, so I decided to build my own driver. Here’s how it went.

The tutorial walks you through the creation of the queue class that extends the "Queue" interface already built into Laravel (and what methods it requires). It then mentions the custom connector class it'll require and the service provider to link it all together. There's also a section covering the configuration you'll need to define the queue properties and what changes you'll need to make.

tagged: tutorial custom queue driver laravel interface configuration serviceprovider

Link: https://dotdev.co/creating-a-custom-queue-driver-for-laravel-3ec6463fa881#.grumknpj8

Eleven Labs Blog:
RabbitMQ: Publish, Consume, and Retry Messages
Feb 03, 2017 @ 12:53:06

On the Eleven Labs blog they're posted a tutorial showing you how to integrate RabbitMQ functionality into your Symfony-based application making use of a few handy tools that do some of the heavy lifting for you and how messages are handled (and what to do when they error).

RabbitMQ is a message broker, allowing to process things asynchronously. There’s already an article written about it, if you’re not familiar with RabbitMQ.

What I’d like to talk to you about is the lifecycle of a message, with error handling. Everything in a few lines of code. Therefore, we’re going to configure a RabbitMQ virtual host, publish a message, consume it and retry publication if any error occurs.

They use the RabbitMQ admin toolkit and Swarrot packages to get the job done. First up is the configuration of the tools, creating a default_vhost.yml file defining a queue and setting up the exchanges and parameters for the default route ("/"). They show an example of what the RabbitMQ UI looks like with this new exchange up and working and how to get more information about this "default" queue. Next up is the consumption and publication of messages. They include an example app/config/config.yml file that defines some settings the Swarrot library (via the SwarrotBundle) needs to understand the connections, consumers and type of provider to use. Finally he shows the configuration so it all knows how to publish messages and a quick example of PHP code that sends a simple string message to be handled by the RabbitMQ workers. The post ends with a bit more configuration and some examples of how to handle errors in this Swarrot/RabbitMQ Admin Toolkit setup and making use of some middleware to help with message retries and number of attempts.

tagged: tutorial rabbitmq symfony bundle swarrot configuration publish consume retry error

Link: http://blog.eleven-labs.com/en/rabbitmq-publish-consume-retry-messages/

Master Zend Framework:
How To Generate Dependency Configuration's Easily with ConfigDumper
Jan 24, 2017 @ 13:45:26

The Master Zend Framework site has a new tutorial posted showing how to generate dependency configurations easily with the help of the ConfigDumper component is a Zend Framework based application.

Want to save time generating dependency configuration files for your Zend ServiceManager dependencies? In today's tutorial, I'll show you how, by using ConfigDumper, available in ServiceManager 3.2.0.

In the previous tutorial, we saw how to use FactoryCreator’s command-line tool, generate-factory-for-class, to quickly and easily create factories for classes.

In this, the follow-up tutorial, we’re going to see how to use generate-deps-for-config-factory, the command-line tool for ConfigDumper, to save time when generating dependency configuration files for use with our classes.

He starts by helping you get the correct version of the ServiceManager installed (3.2.0) and provides an overview of the generate-deps-for-config-factory tool. He moves on to a simple example using one of the included classes (the PingAction) and calls the generator with an example of the results. From there he includes a more complex example using the HomePageAction as its source. He points out that this tool doesn't work for every class and gives an example of a failure around a missing type hint. The post wraps up with a look at the ConfigAbstractFactory and how you can use the configurations that result from using the generation tool.

tagged: zendframework dependency configuration configdumper tool servicemanager tutorial

Link: http://www.masterzendframework.com/dependency-config-generation-with-configdumper/

Amine Matmati:
Symfony: the Myth of the Bloated Framework
Dec 20, 2016 @ 12:25:50

Amine Matmati has written up a post with a few quick points refuting the "bloated framwork" myth as it relates to the Symfony framework.

At work, we’re trying to choose which PHP framework to use for our next project. As we’re breaking up our monolithic app into services, only micro frameworks were considered by the team. This choice was made to avoid the pain points we’ve encountered using our current full stack framework.

Not all full stack frameworks are created equal, however. Having worked with Symfony before, I proposed it as an option. As expected, I’ve had some pushback from my fellow coworkers. The main reason being that Symfony is bloated and overkill for our needs.

He then goes on to talk about how, despite many Symfony components being used individually by other projects, the overall framework still has the reputation for bloat. He goes through some of the main points usually mentioned by the opponents:

  • Doctrine is complex/bad/slow
  • Symfony is too verbose
  • Symfony uses too much configuration

He does agree with some of the points made but usually not in the general way they've been stated. For example, while he does agree that Symfony is verbose he also points out that this verbosity provides more control to the developer as to exactly how things hook together.

tagged: symfony myth bloated framework opinion doctrine configuration verbose

Link: http://matmati.net/symfony-myth-bloated-framework/

Sending Email with SES in CakePHP 3
Dec 08, 2016 @ 09:31:21

The StarTutorial site has a new article posted showing you how to send email via SES in a CakePHP 3 application. SES is a service from Amazon Web Services that makes it simpler to send emails, the Simple Email Service (SES).

In this tutorial, we will show you how to set up CakePHP 3 to send email with AWS SES via SMTP. In our opinion, integrating AWS SES with CakePHP 3 by SMTP is more straightforward comparing to API.

They start off with the creation of the "EmailTransport" profile configuration dropped into the main application configuration file (defining connection and credential information). They then show how to create an "email profile" telling the framework to use the SES service definition. Finally they offer some advice about using the SES service on a Google Cloud instance and how to work around some of their port restrictions. CakePHP takes care of the rest, automatically understanding how to work with SES and using it transparently as the mailing service when you send your emails.

tagged: cakephp3 tutorial email aws ses send email configuration googlecloud

Link: https://www.startutorial.com/articles/view/sending-email-with-ses-in-cakephp-3