Archive for the ‘Php News’ Category

PHPMaster.com: REST – Can You do More than Spell It? Part 2

On PHPMaster.com today they’ve posted their series on “speaking REST” (part one is here), developing a PHP-based RESTful framework.

In the first article of his series, David explained how REST is more than an architectural pattern. It’s a set of guiding principles that, if followed, can help you write scalable and robust applications. In the following articles, David will resume the discussion by looking at REST from the client-side of the equation. In this article though I’d like to focus on the server-side. You’ll learn how to shift your thinking from the action-focused mindset that’s prevalent in web development today to a more RESTful, resource oriented, approach, and see one way to structure your code and route URI requests in PHP.

He talks about the change in mindset it takes to create an effective, resource-focused RESTful service and shows some of the initial steps towards getting it all down in code (based on a simplified “front controller” that routes the request appropriately). The resources are defined as classes (like the “Restaurant” in their example) which then handles the type of request based on the request type (GET, POST, etc).

Web and PHP Magazine: Issue #2 Released – “PaaS with Flying Colors”

The latest issue (second) of the “Web and PHP Magazine” has been released. Articles in this issue include:

  • An interview with Colin Hayhurst, co-founder of StackBlaze, on running a PHP startup
  • A preview of PHP Summit 2012 UK
  • Stefan Priebsch (thePHP.cc) on how to see the bigger picture (application architecture)
  • ‘PaaS: The Cloud On-Ramp For PHP Developers’ (by Lucas Carlson of AppFog)
  • ‘Cryptography In PHP’ (by Enrico Zimuel of Zend)

Once again, you can download this issue for free to enjoy!

Sebastian Göttschkes’ Blog: Extending the Testclass for Unittests

In his previous post Sebastian Göttschkes introduced a set of classes you could use for different types of testing in your Symfony2 applications. In his most recent post he expands on these examples, giving the UnitTestClass an extra ability.

In one of my last articles on Testclasses for symfony2 I explained some of the classes I use for my tests. Since then I found a great article on metatesting and want to update my UnitTest class to show some practical examples.

His update allows the class to access private properties via a “getAttribute” method that, via PHP’s Reflection, allows you to pull out the private property’s value and a “setAttribute” that lets you inject a value back in. He includes a word of warning, though – if you’re using something like this often., you’re probably “doing it wrong” and might need to think through your application design a bit more.

You can find the source for his classes in his previous post.

Voices of the ElePHPant Podcast: FIG, FUD & FOMO

On the Voices of the ElePHPant podcast, the latest episode has been released – FIG, PUD & FOMO, a discussion with members of the PHP Standards Group: Matthew Weier O’Phinney, Jeremy Lindblom and Paul Jones.

Cal‘s questions center around the Standards group and what kinds of discussions they have about the language and the progress the group has made so far (like PSR-0):

  • What’s the purpose of the group?
  • Is the purpose of this group to take PHP from everyone’s hands and enforce the “one true grace” on everyone?
  • Is the group fulfilling its purpose or is it wandering off the path?

You can listen to this latest episode either via the in-page player, by downloading the mp3 or subscribing to their feed.

Kevin Schroeder’s Blog: ZF2 Dependency Injection – Multiple Object Instances

Kevin Schroeder has a quick new post about using dependency injection in Zend Framework 2 applications using multiple object instances.

When you work with the ZF2 Dependency Injection Container (DiC) when you make multiple requests for an instance of an object you will get the same object back each time. [...] But what if you want the injection benefits of the DiC but don’t want to share the object? Use the DiC’s newInstance method instead with the third parameter being false.

He includes code examples of requesting the object both ways – the usual way that returns the same object and the alternative that passes in a “false” value, complete with a debug output of each object proving they’re different.

Marcelo Gornstein’s Blog: PHP Continuous integration, with Jenkins and Phing

On his site Marcelo Gornstein has published a new guide to getting a basic automated continuous integration server set up with Jenkins and Phing.

This article is about how to use Phing in your projects, so a continuous integration server (in this case Jenkins -ex Hudson-) can generate the necessary artifacts for your php application (deployment artifacts, documentation, code metrics, etc). I’ll try to show why this will make your life easier when developing or auditing code, generating releases and deploying new versions, trace bugs, etc. All with just a handful of phing tasks.

He introduces the Phing tool and explains how it makes automating the steps of your process simpler, relating it to the Apache Ant tool for those familiar with it. He links to several of the resources used in the process including PHPMD, PHPLoc, DocBlox and the code for the article itself. He outlines the process and, complete with a screenshot of the final result, shows you how to get everything configured and running smoothly.

Seth May’s Blog: The 5 Ws of Data Validation – Part 1

With a reminder about the best practice of always validating your data, Seth May has this new post about the “Five Ws” of validation – why, when, where and who.

As web developers, the applications you write are complex data processing engines. They try and convince your users to enter good, meaningful data and to respond in solid, predictable ways based on what was entered. Robust data validation will allow the rest of you application to work effectively. [...] Data is scrutinized in various ways to make sure that it adheres to basic restrictions and to fundamental properties. It’s no good receiving a sandwich when you expect a car.

The questions he answers are:

  • Why is Data Validation Important?
  • Where Should I be Validating Data?
  • When Should My Data Be Validated?
  • Who is Responsible for Validation?
  • How Do I Validate My Data? (yes, there’s a “w” in there!)

In the real world data is ugly, crazy, and untrustworthy. Your only hope to taming the data beast is to diligently, methodically validate your data.

Pim Elshoff’s Blog: In favour of typing

Pim Elshoff has a new post to his blog that shares his preference on typing (keystrokes, not variables) in applications (hint: he likes it):

We sometimes conceive of ideas that are arduous to express in code. Like persisting data, or some other uncommon task (sarcasm). It’s not difficult, but it takes a lot of keystrokes to write. Being problem solvers, we find it difficult doing this kind of manual labour, especially when machines can do it for us. Still, I would like to take this opportunity to say that typing rocks and solutions that save typing suck.

He talks about the abstraction that frameworks provide (less typing, more work) and and some of the “magic” that comes with them. He gives specific examples of some of his pervious experience with frameworks (including some pains with Symfony2) and how some of the magic he’s seen is easy to write but hard to read.

Juan Treminio’s Blog: Setting Up an Ubuntu VM, Step by Step

Juan Treminio has a recent post to his blog showing the complete steps you’ll need to get a virtual machine up and running (using VirtualBox and a Ubuntu Seerver install), complete with PHP, MySQL, Samba and Apache.

Recently on r/php there was a thread asking users about their development environments. The usual answers came tumbling out – mostly about IDEs and methods for uploading their code (side note: FTP is a horrible way to do this!). Out of 144 responses, I noticed that very few mentioned virtual machines. Most that said anything about operating systems or platforms made it clear they were developing on their local machine, with no separation between their everyday driver and their development environment. This has got to stop, especially amongst PHP developers where we have tools like XAMPP that require nothing more than a simple zip extract to get up and running with your own “server”.

He walks you through the entire process, complete with screenshots and commands ready for copy & paste, to get your virtual machine server set up and working. The PHP install includes things like cURL, memcache, internationalization, GD and MySQL support. He also helps you get other tools like XDebug and PHPUnit installed.

This is definitely one of the more complete examples I’ve see of getting a VM set up and ready for development – if you’ve been wanting to try it out, I’d recommend this guide.

SitePoint.com: SitePoint Podcast #159: PHP Master with Tim Boronczyk

On SitePoint.com today there’s a new podcast posted, an interview with Tim Boronczyk, the managing editor of their PHPMaster tutorial site.

Episode 159 of The SitePoint Podcast is now available! This week our regular interview host Louis Simoneau (@rssaddict) interviews Tim Boronczyk (@zaemis), the Managing Editor of phpmaster.com about the new features in PHP5.4, PHP’s strengths and weaknesses, and the DIY approach of the PHP community.

You can listen to this latest episode either via the in-page player, by downloading the mp3 directory or subscribing to their feed.