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

SitePoint PHP Blog:
Validating your data with Respect Validation
Jul 20, 2015 @ 10:49:26

The SitePoint PHP blog has posted a tutorial showing you how to validate your data with Respect (well, their validation library) and ensure the data you're getting is exactly what you're expecting.

Validation is an important aspect of every application’s interaction with data. Instead of reinventing the wheel every time, the community collaborated on some useful packages like Symfony, Laravel, Zend, etc. In this article, we’re going to introduce a lesser known package called Respect Validation, which provides some nice new features.

He starts by mentioning some of the other popular validation packages used widely in the PHP community including the Symfony Validator and Laravel's Illuminate package. For each of these he shows code validating an email address, each with their own slight differences. Using this same example he shows how to implement it in the Respect library, first making use of their custom "email" validator class then via custom chained rules. He also shows how to set custom error messages and provides a more "real world" example with a simple Laravel application. His application takes in user data including username, password and credit card information and uses Respect's library to validate it via a full set of rules. He ends the post with a quick look at creating your own custom rule classes and how to "cross pollinate" them with Zend or Symfony validators.

tagged: respect validation library tutorial laravel example custom errormessage

Link: http://www.sitepoint.com/validating-your-data-with-respect-validation/

Symfony Blog:
Symfony2: Getting easier
Apr 29, 2011 @ 10:09:17

On the Symfony blog there's a new post about how Symfony2 is "getting easier" thanks to some recent changes with improved error handling and simpler configuration options.

With the release of the first beta approaching fast, our main focus has switched from adding new features to polishing existing ones. [...] Recently, Ryan and I have spent our time tweaking error messages, simplifying the code and the configuration, adding more documentation, and making things more consistent throughout the framework. The goal is to ease the learning curve and make things that people will need on a day to day basis simpler.

The changes they've made include three updates - better Twig error messaging, better configuration error messaging and some helpful changes to the Doctrine configuration to allow for auto-mapping of connections when the traditional one-database setup is used.

tagged: symfony2 framework simile errormessage configuration doctrine

Link: