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

AWS Developer Blog:
Automating the Deployment of Encrypted Web Services with the AWS SDK for PHP (Pa
Feb 17, 2017 @ 12:25:48

The Amazon Web Services blog has posted the second part of their series covering the automated deployment of encrypted web services with the AWS SDK. In this new tutorial (part two, part one is here) they continue with the deployment of services: AWS Elastic Beanstalk, Amazon Route 53 and Amazon CloudFront.

In the first post of this series, we focused on how to use Amazon Route 53 for domain registration and use Amazon Certificate Manager (ACM) to create SSL certificates. With our newly registered domain available for use, we can proceed to deploy and configure the services we need to host the www.dev-null.link website across an encrypted connection. Once complete, the infrastructure configuration will reflect the diagrams [included in the post].

The tutorial then walks you through each of the services you need to deploy and shares the code (using the AWS PHP SDK) to show how to automate the process. There's also a few screenshots included of various page results and admin UIs to help you be sure you're in the right place.

tagged: aws amazon deployment encrypted webservice sdk tutorial series part2

Link: https://aws.amazon.com/blogs/developer/automating-the-deployment-of-encrypted-web-services-with-the-aws-sdk-for-php-part-2/

Matthias Noback:
Containerizing a static website with Docker (Part 1 & 2)
Jan 06, 2017 @ 09:07:39

Matthias Noback has started a series to his site showing you how to use Docker along with a static site, like one generated with Sculpin to create a complete environment. So far he's posted part one and part two.

Recently a former colleague of mine, Lucas van Lierop, showed me his new website, which he created using Spress. Lucas took two bold moves: he started freelancing, and he open-sourced his website code. This to me was very inspiring. I've been getting up to speed with Docker recently and am planning to do a lot more with it over the coming months, and being able to take a look at the source code of up-to-date projects that use Docker is certainly invaluable.

Taking lots of inspiration from Lucas's codebase, and after several hours of fiddling with configuration files, I can now guide you through the steps it took to containerize my blog (which is the site you're visiting now) and deploy a single container to a production server.

In part one he talks about how his blog is currently set up - based on a "large set of Markdown files" - and using Sculpin to generate the resulting site. He walks through the configuration of the Sculpin installation and how to configure and build the initial container, the "build" container.

In part two he continues the process but creates a "blog" container this time. This container runs the web server itself (nginx) configured as required by the Sculpin formatting.

tagged: container docker static website tutorial series part1 part2

Link: http://php-and-symfony.matthiasnoback.nl/categories/Docker/

Scaling Laravel Using AWS Elastic Beanstalk Part 2: Setting up VPC, RDS and Ela
Dec 15, 2016 @ 10:56:06

On the DeliciousBrains.com site they've posted the second part of a series covering the scaling of a Laravel-based application using Elastic Beanstalk (part one is here).

In my last article we decoupled Laravel and got it ready for deployment to the Elastic Beanstalk architecture. However, before we race ahead to actually deploying our code to Elastic Beanstalk we need to do some preparation first. Specifically we need to set up some other AWS services that will be used by our Laravel app. These include: Virtual Private Cloud (VPC) to keep our infrastructure secure, Relational Database Service (RDS) for our MySQL database and ElastiCache for our Redis cache

With these “supporting” services up and running we can finally move on to deploying our Laravel app to Elastic Beanstalk.

They start off by walking you through the creation of the VPC on the AWS services using both public and private subnets. With that in place they move on to the RDS setup, configuring it to host their MySQL database and making a test connection. Finally they set up the ElastiCache instance for the Redis handling finishing out their "supporting services" setup in AWS.

tagged: laravel aws elasticbeanstalk series part2 vpc rds elasticache tutorial

Link: https://deliciousbrains.com/scaling-laravel-using-aws-elastic-beanstalk-part-2-setting-up-vpc-rds-elasticache/

Object-Oriented Autoloading in WordPress, Part 2
Nov 30, 2016 @ 09:33:08

The TutsPlus.com site has posted the next tutorial in their "Object-Oriented Autoloading in WordPress" series - part two - expanding on the basics presented in the previous part of the series.

In the previous tutorial, we covered a handful of concepts, all of which are going to be necessary to fully understand what we're doing in this tutorial. Specifically, we covered the following topics: object-oriented interfaces, the single responsibility principle, how these look in PHP [and] where we're headed with our plugin.

[...] Ultimately, we won't be writing much code in this tutorial, but we'll be writing some. It is, however, a practical tutorial in that we're performing object-oriented analysis and design. This is a necessary phase for many large-scale projects (and something that should happen for small-scale projects).

First they briefly cover the environment you'll need to follow along (already set up if you followed along with part one). They then get back into the code, evaluating the current state of the custom autoloader and investigating how it can be broken down into a class and a set of methods instead of procedural code. They work through the different functional parts of the autoloader and how to break it down into classes with only one job (the "single responsibility principle"). They end up with the autoloader that uses NamespaceValidator, FileInvestigator and FileRegistry instances to get the job done.

tagged: oop objectoriented wordpress part2 series refactor singleresponsibility principle

Link: https://code.tutsplus.com/tutorials/object-oriented-autoloading-in-wordpress-part-2--cms-27431

Using Namespaces and Autoloading in WordPress Plugins, Part 2
Nov 03, 2016 @ 11:55:25

The TutsPlus.com site has continued their series looking at namespace-based autoloading in WordPress applications with part two. In this latest article they build on the simple plugin from part one and enhancing it with more functionality and autoloaded classes.

In the previous tutorial, we began talking about namespaces and autoloading with PHP in the context of WordPress development. And although we never actually introduced either of those two topics, we did define them and begin laying the foundation for how we'll introduce them in an upcoming tutorial.

Before we do that, though, there's some functionality that we need to complete to round out our plugin. The goal is to finish the plugin and its functionality so that we have a basic, object-oriented plugin that's documented and works well with one caveat; it doesn't use namespaces or autoloading.

This, in turn, will give us the chance to see what a plugin looks like before and after introducing these topics.

They start off with a quick review of the setup and previous development work done on the plugin making it easier to load in Javascript templates in a dynamic way. The plugin is then ready to start helping with the plugin use. They add in a basic CSS file to the site's "assets" folder and enqueue it. They start updating the plugin code, adding in an assets interface, a CSS loader and some styling for the box shown on the edit post interface.

tagged: namespace autoload wordpress plugin introduction part2 series autoload css loader

Link: https://code.tutsplus.com/tutorials/using-namespaces-and-autoloading-in-wordpress-plugins-part-2--cms-27203

Master Zend Framework:
How to Build a Docker Test Environment
Sep 28, 2016 @ 11:20:40

The Master Zend Framework site continues their series covering the creation of a Docker-based testing environment in this second part highlighting the addition of testing support.

In the first part in this series on developing web applications using Docker, we saw how to create a local development environment using Docker; one ideally suited to creating Zend Expressive (or any other kind of PHP-based web application). But, what we didn’t cover was how to handle testing in a Docker-based environment.

[...] How do you run tests when working with Docker containers? After a bit of searching, I found that it’s not that difficult. But you have to use the right combination of commands.

Since unit tests can be run locally if need be (they shouldn't need any resources from the service if they're true unit tests) he focuses on acceptance testing. For his examples he uses the Codeception testing tool. He walks you through the setup of some simple tests based on the "home" page functionality of the Zend Expressive skeleton application. With that in place, he shows the updates that will need to be made to execute the tests from outside the instance via a "docker exec" call. The post finishes with a look at adding two other tools to the mix as well: Make and Phing.

tagged: docker test environment series part2 testing acceptance codeception make phing

Link: http://www.masterzendframework.com/how-to-build-a-docker-test-environment/

SitePoint PHP Blog:
PHP, Arduino, And… Minecraft? Connecting an Arduino to PHP!
Jul 12, 2016 @ 10:39:38

The SitePoint PHP blog has continued their series looking at connecting the real world with the online world via Minecraft and an Arduino. In this new post author Christopher Pitt picks up where he left off in part one and brings the Arduino in to the picture.

In the first part of this series, we learned a bit of Minecraft and the circuitry we can make inside it. We also made a circuit to alert us when the door to our mansion was opened. We then hooked this virtual alarm to a listening PHP script, so we can know when the door is opened in the context of a PHP script.

In this part, we’ll build a small Arduino-based alarm circuit. We’ll learn how to trigger the alarm, using the the official IDE and programming language, and then using something called Firmata. We’ll round the series out by connecting the alarm circuit to the Minecraft circuit, so we hear a real alarm for Minecraft mansion.

He takes some time at the beginning of the post introducing the Arduino hardware and what they have to offer. He lists the parts you'll need for this setup to work and how they need to be set up. He then gets into the code for the Ardunio side and how to get it over to the board. He presents another option to the potentially painful change-reupload cycle of debugging Arduino code: using the PHP "carica/firmata" library to connect to and add listeners to hook into the board. He uses this to then set up a PHP script to watch for changes in the Minecraft log files and fire an event to the waiting Arduino board.

The final item in this part of the tutorial series talks about bringing in the "Gorilla" extension for Carica Firmata to help prevent issues with too fast connections to the board interrupting the boot sequence.

tagged: tutorial series part2 minecraft arduino alarm connecting event loop

Link: https://www.sitepoint.com/php-arduino-and-minecraft-connecting-an-arduino-to-php/

Davey Shafik:
Community Relations: Not Just a Megaphone
Jul 11, 2016 @ 10:49:04

Davey Shafik has continued his series of posts with advice about growing a community around your product/open source libraries. In his first post he talked more about how to engage the community. In this latest post he talks about the role of "evangelists" in community relations (and why he dislikes the term).

The role of the Community Builder is to sell you on the idea of the company and the product. Not necessarily to sell you the product. Often times what we’re selling are not bought without some decision making process behind them, so a sale is not going to happen then and there anyway. Provide the education, and build the trust, and the sale will happen.

Davey then talks about why he hates the term "evangelist" and how it seems to relate more to "fanatic" than "advocate". He then gets into what he sees as the role of an advocate, including the role honesty plays and selling the customer on the right product. He then turns it around and talks about the other side of the role - advocating for the customer back to the rest of the company. Finally, he talks about two other kinds of advocacy that should also be included in the role: advocating for the community/their input and for yourself (finding a product you can be passionate about selling).

tagged: community relation megaphone building advocate evangelist opinion series part2

Link: https://daveyshafik.com/archives/70035-community-relations-not-just-a-megaphone.html

Internationalizing WordPress Projects: A Practical Example, Part 1
Jul 06, 2016 @ 10:50:43

Tom McFarlin has continued his series covering internationalization in WordPress applications with this latest part of the series. In the previous part of the series he introduced some of the basic topics and terms. In this new tutorial he gets more into functionality creating the plugin he'll use in his examples.

Given that WordPress powers roughly 25% of the web and that the web is not local to your country of origin, it makes sense to ensure that the work that we produce can be translated into other locations.

To be clear, this does not mean that you, as the developer, are responsible for translating all of the strings in your codebase into the various languages that your customers may use. Instead, it means that you use the proper APIs to ensure someone else can come along and provide translations for them.

He then walks you through the download of the latest WordPress version (a Subversion checkout) and the creation of the plugin structure. He provides sample code to define the plugin and shows how it should look in the "Plugins" listing. He helps you add in the menu item with internationalized strings for the link text. They help you add a simple screen for the plugin and help you style the page a bit. The post ends with a brief mention of object-oriented programming but points out that OOP introduces other, not necessarily related, topics that could detract from the WordPress-related content (and so will not be used).

tagged: wordpress internationalization i18n tutorial series part2 plugin example practical

Link: http://code.tutsplus.com/tutorials/internationalizing-wordpress-projects-a-practical-example-part-1--cms-26676

Using PHP CodeSniffer With WordPress: Installing and Using PHP CodeSniffer
Jun 15, 2016 @ 12:38:21

The TutsPlus.com site has posted the next part of their series showing the use of the PHP CodeSniffer tool with WordPress. In the first part of the series they introduced "code smells" and build on that in part two with the installation and use of PHP CodeSniffer to detect these smells.

In the first article of this series, we defined code smells and looked at a few examples of what they are and how we may refactor them so the quality of the code is improved.

[...] Ultimately, we're working towards implementing WordPress-specific code sniffing rules, but before we do that it's important to familiarize yourself with PHP CodeSniffer. In this article, we're going to take a look at what PHP CodeSniffer is, how to install it, how to run it against an example script, and how to refactor said script. Then we'll look at how we're going to move forward into WordPress-specific code.

The tutorial then shows you how to get the tool installed using Composer, not the PEAR method. They help you install Composer then create the simple project with a composer.json configuration file defining the dependency. They provide a sample bit of code to run the analysis against and an example of the output showing violations of the coding standard.

tagged: wordpress tutorial phpcodesniffer coding standards series part2

Link: http://code.tutsplus.com/tutorials/using-php-codesniffer-with-wordpress-installing-and-using-php-codesniffer--cms-26394