News Feed
Sections




News Archive
feed this:

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

AirPair.com:
Best Practices for Modern PHP Development
December 05, 2014 @ 09:50:22

On the AirPair site today they've posted an article from developer Brian Fenton covering several things he sees as the best practices for modern PHP development, a listing of several tool, practices and suggestions to improve your skills as a PHP developer and bring them to the next level.

He breaks it down into five main sections (each with their own subsections):

  • Setup and configuration
  • Use Composer
  • Follow good design principles
  • Object calisthenics
  • Unit testing

Some of the points made under each of these sections include suggestions about using sensible defaults, installing and using Composer, the SOLID design principles and unit testing tools. Check out the full post for more great suggestions and techniques to improve your skills.

0 comments voice your opinion now!
bestpractices modern development tips list composer objectcalisthenics unittest

Link: https://www.airpair.com/php/posts/best-practices-for-modern-php-development

NetTuts.com:
Unit Testing Succinctly Why Unit Test?
October 16, 2014 @ 12:06:05

NetTuts.com has kicked off a new series of posts today that answers the question "Why unit test?" The series, Unit Testing Succinctly aims to define what unit testing is, approaches to implementing them and what they can do to help you and your application.

The usual mantra we hear regarding any software methodology is that it improves usability and quality, reduces development and testing time, and brings the product to market faster and with fewer bugs. These are lofty goals, but I have yet to see a methodology deliver the Grail of software development. Ultimately, the primary reason to write unit tests is to prove correctness, and this happens only if you write unit tests well.

In this first post they cover three of the more general reasons for making the dive into unit testing your applications at all. These are more "business value" kinds of ideas but they trickle down into the development level, providing value for the developers too.

  • Measuring Correctness
  • Repetition, Repetition, Repetition
  • Code Coverage

Their main point to reinforce is the first of the three, though. Unit testing helps to measure and ensure correctness of both the code itself and the functionality it performs.

0 comments voice your opinion now!
unittest introduction why correctness coverage repeatability

Link: http://code.tutsplus.com/articles/unit-testing-succinctly-why-unit-test--cms-22410

Dave Marshall:
Mockery Spies
October 09, 2014 @ 10:29:08

In his latest post Dave Marshall takes a look at a handy feature of the Mockery mocking tool (helpful for unit testing) and how to use them in your testing.

Spies have been on the cards for mockery for a long time and even after putting together an implementation in February, I kind of stalled out on making a decision on the public API. Fast forward a few months and I figured it was just time to ship it, so I went with the most mockery like API and merged it in. Mockery still doesn't have a 1.0 release, so I can always make changes before we go 1.0.

For those not familiar with the concept of "spies" in testing he includes a brief definition and some of the reasoning behind using them. The first is relatively simple: how they can reveal the intent of the test. They also allow for two other types of testing methods, "Arrange-Act-Assert" or "Given-When-Then" thinking patterns. He does mention, however, some of the problems with using spies over mocks (including that they're less precise, possibly leading to looser testing). He finishes up the post with a quick note about partial spies and how they can provide a nice compromise in your testing.

0 comments voice your opinion now!
mockery unittest spies doubles mock compare feature

Link: http://davedevelopment.co.uk/2014/10/09/mockery-spies.html

SitePoint PHP Blog:
Interactive PHP Debugging with PsySH
September 30, 2014 @ 12:53:30

The SitePoint PHP blog has a new tutorial posted by i>Miguel Ibarra Romero showing how to use the PsySH tool to do some interactive debugging of your PHP applications via both the command line and a web frontend.

It's 1:00 a.m., the deadline for your web application's delivery is in 8 hours… and it's not working. As you try to figure out what's going on, you fill your code with var_dump() and die() everywhere to see where the bug is. [...] Is this situation familiar to you? PsySH to the rescue. PsySH is a Read-Eval-Print Loop (or REPL). You may have used a REPL before via your browser's javascript console. If you have, you know that it possesses a lot of power and can be useful while debugging your JS code.

He walks you through the install via Composer and some of the basic commands and syntax for executing PHP code inside its shell. Command line testing is good, but debugging full applications is a bit more difficult. He shows how to integrate the tool into a sample application that calls PsySH via a "debug" call and output via a set of "window" objects. He also includes a bit close to the end about debugging with unit tests, executing them from inside the shell as well.

0 comments voice your opinion now!
interactive debugging psysh repl unittest commandline web

Link: http://www.sitepoint.com/interactive-php-debugging-psysh/

Ben Ramsey:
Learning a New Codebase
September 18, 2014 @ 09:38:51

In a new post to his site Ben Ramsey shares a few suggestions around things to ask and do to learn a new codebase (whether that means in a new job or coming into a new open source project).

A few days ago, my friend Ed Finkler started a new job. Earlier this week, he posted on Twitter: "First days humble us all." Having begun a new job myself, I shared Ed's sentiment. Last weekend, while at the Madison PHP Conference, we were discussing what developers can do during the interview process to get an idea of the kind of codebase a company has.

He includes a few questions for developers to ask, either during the interview or once hired, about the codebase itself including:

  • what coding standards the company follows
  • how much of the code is covered by tests
  • have the company's deployment process described

He also recommends learning the codebase by diving in and either writing tests for untested areas or work through bug reports and fix (then test) them.

0 comments voice your opinion now!
learn new codebase tips questions bugfix unittest

Link: http://benramsey.com/blog/2014/09/learning-a-new-codebase/

Community News:
Laravel Framework Introduces Liferaft
September 12, 2014 @ 09:25:04

The development group behind the Laravel framework have introduced a new tool that aims to make it easier to report bugs with the framework (not the applications built with them): Laravel Liferaft.

To encourage active collaboration, Laravel currently only accepts pull requests, not bug reports. "Bug reports" may be sent in the form of a pull request containing a failing unit test. [...] A failing unit test or sandbox application provides the development team "proof" that the bug exists, and, after the development team addresses the bug, serves as a reliable indicator that the bug remains fixed.

Following along with this method, Liferaft provides a simple way to download a clean copy of the framework, make the needed changes for the pull request and automatically submit it via GitHub back to the project for handling. In this video on Laracasts Taylor Otwell walks you through a simple example of using it to submit an issue back (and what happens behind the scenes).

0 comments voice your opinion now!
liferaft laravel framework bugfix unittest pullrequest

Link: https://laracasts.com/lessons/introducing-laravel-liferaft

NetTus.com:
Understanding PhpSpec
September 04, 2014 @ 11:09:42

The NetTuts.com site (well, TutsPlus) has posted a new tutorial that gets you more intimate with PhpSpec, a PHP-based testing tool that lets you define tests as specifications and using behavior-driven development principles. If you need an introduction to the tool, check out this other tutorial first.

If you compare PhpSpec to other testing frameworks, you will find that it is a very sophisticated and opinionated tool. One of the reasons for this, is that PhpSpec is not a testing framework like the ones you already know. Instead, it is a design tool that helps describing behavior of software. A side effect of describing the behavior of software with PhpSpec, is that you will end up with specs that will also serve as tests afterwards. In this article, we will take a look under the hood of PhpSpec and try to gain a deeper understanding of how it works and how to use it.

They provide a quick overview of some of the internals of the PhpSpec tool and a brief look at the difference between BDD (behavior-driven) and TDD (test-driven) development practices. There's also a look at how the tool differs from the popular PHP testing tool PHPUnit. Code examples are provided through out the post with simple tests, making the separation between the methods and tools easier to follow.

0 comments voice your opinion now!
tutorial phpspec testing tool bdd tdd unittest behaviordriven development

Link: http://code.tutsplus.com/tutorials/understanding-phpspec--cms-21915

Matthew Weier O'Phinney:
Testing Code That Emits Output
August 25, 2014 @ 09:45:08

In this latest post to his site Matthew Weier O'Phinney gives his suggestion on how to test (unit test) code that provides some kind of direct output. In his case, his script is outputting header information directly, not as a part of a response string.

Here's the scenario: you have code that will emit headers and content, for instance, a front controller. How do you test this? The answer is remarkably simple, but non-obvious: namespaces.

He talks some about the use of namespaces in PHP classes (and methods, and constants...) and how things can be importing using them. He gives an example of an object that outputs some header and body information (an "Output" abstract class). He shows how to use the class in a simple test, calling "reset" in the setup and teardown methods and asserting the contents of the headers and body for expected content.

0 comments voice your opinion now!
test unittest code phpunit output direct namespace tutorial

Link: http://mwop.net/blog/2014-08-11-testing-output-generating-code.html

Ben Ramsey:
Setting Up Jenkins on Amazon Linux for PHP Testing
August 08, 2014 @ 09:36:33

Ben Ramsey has posted a complete walk-through of setting up and configuring Jenkins on an AWS instance for testing your PHP applications.

One of my first tasks at ShootProof was to set up a Jenkins server for continuous integration and get it ready to run unit tests for PHP and JavaScript code. There are plenty of tutorials around the web to help you do just that. This is yet another one, but it's primarily my cleaned-up notes -and less of a tutorial - placed here for my future self to find and provided publicly for all to benefit. These instructions are specifically tailored for setting up Jenkins on an Amazon Linux EC2 instance.

While he doesn't call it a "tutorial" it's still a great step-by-step guide to the things you'll need and the process to follow including commands, installing and starting Jenkins and configuring the environment to execute your tests. The main goal was to set it up for PHP-based applications, but he also throws in the setup of some Javascript testing via Node.js and the PhantomJS/CasperJS combo.

0 comments voice your opinion now!
jenkins tutorial amazon aws instance setup configure linux unittest

Link: http://benramsey.com/blog/2014/08/setting-up-jenkins-on-amazon-linux-for-php-testing/

NetTuts.com:
Refactoring Legacy Code Part 9 - Analyzing Concerns
July 24, 2014 @ 11:27:56

The NetTuts.com site has posted part nine in their series sharing helpful hints and methods for refactoring legacy code. In this new post they continue on with their example application and look at where methods should be moved to/created and mocking in their tests.

In this tutorial, we will continue to focus on our business logic. We will evaluate if RunnerFunctions.php belongs to a class and if so, to which class? We will think about concerns and where methods belong. Finally, we will learn a little bit more about the concept of mocking.

They show how to move some of the "Runner" functions from procedural to OOP, integrating them with some of the classes and methods that already exist. Tests are also included showing how it all links together. From there they get into concerns about the placement of functionality and how that relates to the work at hand. They also use Mockery to mock out some of the needed objects in their tests for the new structure.

0 comments voice your opinion now!
refactor legacy code series part6 concerns functionality mock unittest

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-9-analyzing-concerns--cms-21760


Community Events





Don't see your event here?
Let us know!


symfony interview version release opinion composer voicesoftheelephpant laravel tool library community security language artisanfiles introduction list conference framework podcast series

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework