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

Piotr Pasich:
Automated deployment with AWS Elastic Beanstalk (EB) – Part II
Aug 07, 2015 @ 09:14:31

Piotr Pasich has posted the second part of his series showing you how to set up an automated deployment process for an environment that includes an Elastic Beanstalk instance. In this part of the series be builds on the process created in part one and shows the setup and configuration of the Beanstalk instance.

In the previous part we set up a dedicated Symfony application on Docker virtual containers and prepared environments that may be transferred between developers during project cycle. The next step is to prepare the application for pushing into the cloud. There are many options available on the market – Heroku, DigitalOcean and, my favorite, AWS Elastic Beanstalk.

He walks you through the Amazon side of things first, getting the Beanstalk instance set up through the AWS control panel, selected from the AWS list of services. He goes through the options you'll need to configure to get the instance all set up and running including the resources to allocate and instance type (t1.medium is recommended). He then helps set up some of the necessary environment variables for configuration information and a bit of a hack to Symfony that lets you override local parameters with ones coming from the environment. Finally he configures the Beanstalk application and setting it up for automated deployment.

tagged: series part2 elasticbeanstalk aws deployment automated tutorial

Link: http://piotrpasich.com/automated-deployment-with-aws-elastic-beanstalk-eb-part-ii

SitePoint PHP Blog:
Automated Testing of Drupal 8 Modules
May 04, 2015 @ 11:06:08

The SitePoint PHP blog has a tutorial posted talking about the automated testing of Drupal 8 modules, the components of the popular PHP-based content management system. In it author Daniel Sipos shows how to create a few tests for some functionality created in previous articles.

In this article we are going to look at automated testing in Drupal 8. More specifically, we are going to write a few integration tests for some of the business logic we wrote in the previous Sitepoint articles on Drupal 8 module development. [...] But before doing that, we will talk a bit about what kinds of tests we can write in Drupal 8 and how they actually work.

He makes use of the SimpleTest unit testing tool for PHP (versus something like PHPUnit) as it has become a standard for Drupal's own testing. He talks briefly about what SimpleTest is, how it integrates with Drupal and what kinds of tests already exist. He then gets into testing his own functionality - checking route information, that the page exists, the contents of the resulting page and the addition of a custom block plugin. He shows how to create these simple tests, extending the WebTestBase class, and checking each item on the list. He also includes an example of the resulting output of the successful testing, including time to execute and the detailed results of each test.

tagged: drupal8 automated testing tutorial simpletest introduction exists form custom plugin

Link: http://www.sitepoint.com/automated-testing-drupal-8-modules/

Engine Yard Blog:
Composer & Continuous Integration
Apr 29, 2015 @ 09:14:11

In a new post to the Engine Yard blog Nils Adermann provides an overview of using Composer with continuous integration, its role in the overall process and some good practices to follow in its use.

Continous Integration (CI) is the practice of continuously (and automatically) testing every change a developer makes. So automated tests become an integral part of the development process providing direct feedback on changes made. [...] Davey Shafik's article on Composer's Lock File explains the typical usage of composer install and update. The key takeaway is that developers should run composer update manually to explicitly update individual dependencies while composer install should be used in automated processes. This principle includes automated test environments.

He points out that using the lock file method reproduces the vendor directory exactly as it is in production and what it means for failures in your automated tests. He also talks about methods to improve the build performance to reduce time spent during the generation of the environment, including the use of the Composer cache data. He includes a few flags you can pass to Composer to reduce not only the libraries it installs but also how it fetches their contents.

tagged: composer continuous integration build process performance automated test composerlock

Link: https://blog.engineyard.com/2015/composer-continuous-integration

Squizlabs Blog:
PHP_CodeSniffer 2.0.0 released
Dec 05, 2014 @ 12:03:34

The Squizlabs blog has an announcement about the release of the latest major version of the popular PHP_CodeSniffer tool for PHP - CodeSniffer v2.0. Among the updates in this latest release is a major one - the automated fixing of issues the tool finds.

Nineteen months ago, I started work on a project to allow PHP_CodeSniffer to fix the problems that it finds. Doing this required a lot of changes to the core classes, a lot of iteration and refactoring of the fixing and testing code, and an enormous amount of time and testing across many PHP projects to ensure I am confident enough to release something that actually modifies code. I could keep writing unit tests forever, but I've finally got to a point where I am happy to release this first version of the PHP Code Beautifier and Fixer (PHPCBF), for when you just can't be bothered fixing coding standard errors yourself.

The fixes are made possible through the newly introduced "PHP Code Beautifier and Fixer" (PHPCBF) tool. When the CodeSniffer tool is run against your code the PHPCBF kicks in too and tells you which of the issues can be automatically fixed. Additionally, you can now add custom code to your custom sniffer rules to enable this auto-fix functionality yourself. He also includes a list of the other updates in the release including:

  • a new information report to show you how your code is written rather than if it conforms to a standard
  • the ability to set command line arguments in ruleset.xml files
  • the ability to create your own custom reporting classes and use them with PHP_CodeSniffer
  • support for running on HHVM

You can find out more information about this release in the PEAR or GitHub changelogs.

tagged: phpcodesniffer v2 release automated fix phpcbf

Link: https://www.squizlabs.com/php-codesniffer/2.0.0-released

Automated Testing With Selenium2 And PHPUnit
Nov 25, 2013 @ 10:49:10

On the PHPro.org Kevin Waterson has posted a guide to automated testing with Selenium2 and PHPUnit to create functional tests to check the resulting output of your application.

Selenium2 is a software testing framework for web applications. This tutorial focuses on automating browser testing using Selenium2.

The tutorial walks you through everything you'll need to get started testing with these tools, end-to-end:

  • Selenium installation
  • Writing a first test
  • Setting up the Selenium environment
  • Testing with multiple browsers
  • Assertion types (and examples)
  • Testing form actions and results
tagged: automated testing selenium2 phpunit tutorial

Link: http://www.phpro.org/tutorials/Automated-Testing-With-Selenium2-And-PHPUnit.html

Community News:
phpDocumentor2 Celebrates their (Stable) Version 2.0 Release
Aug 09, 2013 @ 12:04:35

As is mentioned in this new post to the project's releases, Mike van Riel and the contributors to the phpDocumentor2 project have released version 2.0 - the first stable release!

We have spent the past two months fixing bugs, adding tests and writing a brand new template. With this release it is now easier than ever to generate your documentation. And as a special party gift we bring you a brand new template, called Clean. Can't wait to see what it looks like? Then come over and see the demo.

He talks about some of the things yet to come for phpDocumentor including more features based on the PHPDoc standard, improving performance and making the existing systems (and templates) more robust and usable. You can find the full roadmap here. phpDocumentor is one of the most widely used PHP-based tools for generating automated documentation from docblocks already in your code.

tagged: phpdocumentor documentation automated stable release

Link: https://github.com/phpDocumentor/phpDocumentor2/releases/tag/v2.0.0

Automated backups to Google Drive with PHP API
Apr 16, 2013 @ 10:57:01

On his site Lukasz Kujawa has posted a new tutorial showing you how to perform automated backups to Google Drive of files through their API (using his own library).

Where do you keep backups? I guess that depends on what do you backup. You might have a very clever answer for a business critical data but what about less important content? The best example would be a private blog. It will hurt if you lose your data but the odds are you’re not willing to pay for any reliable storage. [...] There is one reliable storage, which is 100% free and almost everybody have access to it. Yes, I’m talking about Google Drive.

He walks you through the process of setting up your Google Drive account API access and where to find the data you'll need to make the connection. He then links over to his project that makes the backup a simple few lines of code (mostly configuration) of a backup path of your choice out to the remote Google Drive account.

tagged: automated backup cp2google library google drive tutorial

Link: http://systemsarchitect.net/automated-backups-to-google-drive-with-php-api

Lorna Mitchell's Blog:
We Don't Know Deployment: A 4-Step Remedy
Apr 18, 2012 @ 11:20:52

In a new post to her blog Lorna Mitchell has written a beginner's guide to deployment for web based applications in response to a recent email from a reader.

I [replied to the email] with some suggestions (and my consulting rate) attached, and we had a little email exchange about some improvements that could fit in with the existing setup, both of the hardware and of the team skills. Then I started to think ... he probably isn't the only person who is wondering if there's a better way. So here's my advice, now with pictures!

She's broken it up into a few different sections to make it a bit more easily digestible:

  • A "starting point" where there's a development, staging and live environments
  • Using source control to manage code
  • Branching for effective coordination
  • Integration of automated deployment

She also mentions other "bonus points" like making a build server, documentation generation and Javascript/CSS minification.

tagged: deployment application process sourcecontrol branching automated


Court Ewing's Blog:
Follow-up: How PHP is Broken and How It Can Be Fixed
Nov 15, 2011 @ 10:18:45

In a follow up to his previous post about how PHP is broken (and what can be done to fix it), Court Ewing has this new post with a few suggestions on how PHP development could be better, but admits that PHP itself is not broken.

It is no secret that the PHP development process has never been a shining example of project organization or quality assurance. Until recently, some of the most important aspects of any project's development cycle were either entirely lacking or were ill-defined. Worse, there was little in the form of systemic quality assurance. Fortunately, the core devs did not ignore these issues, and they've been pushing really hard to improve on these areas over the past few years.

He points out two things that he sees as things that could be improved in the overall process of developing the language - noting that failing automated tests are ineffective and that communication is a key factor in the trust developers have in PHP.

The core PHP developers have long been a key component of [the amazing things the language can do], and none of progress that modern PHP applications have made would be possible without their ongoing efforts. As a result of those efforts, PHP is a stable, secure, and beautifully-practical language that is both easy for novices to wrap their heads around and experts to build the most-used web applications the world has ever seen.
tagged: broken opinion fixed communication automated test fail


Automated code reviews for PHP
Jun 16, 2011 @ 10:06:47

On the Web Builder Zone (a part of DZone.com) Giorgio Sironi take a high-level look at some of the tools you can use for automated code reviews in your projects without you ever having to lift a finger (well, once it's set up, of course).

I'm exploring an approach to automated code review: it's not as precise as the human-based one, but it scales better. [...] All in all, automated code reviews, performed with tools instead of with human intellect, can be a starting point to search for the problematic zones of a codebase. Then the human may come in, since they also have to clean up the code: their intervention was already scheduled.

The tools he mentions (and, in some cases, shows how to install/use) are:

tagged: automated code review tools phpunit phpdepend pmd jenkins