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

NetTuts:
Doctrine ORM and Laravel 5
Nov 19, 2015 @ 16:55:39

On the NetTuts site there's a tutorial posted helping you get familiar with Doctrine 2 (the ORM) and how to integrate it with a Laravel 5 application via a simple service provider.

As a PHP developer, you might have come across the term ORM. ORM is a way to work with databases in the same way you work with classes and objects. If you were to delve deeper into how web applications are designed and built, after doing some exploring in their ORM you would find two well-known patterns: Active Record and Data Mapper.

[...] With Data Mapper the in-memory objects needn’t know that there is even a database present. They need no SQL interface code or knowledge of the database schema. One such solution is Doctrine.

The tutorial walks you through some of the basic concepts in using the Doctrine 2 ORM including Entities and Repositories. Also included is how to pull it in via Composer and update your Laravel configuration to use this bridge library for integrating it into your current application. Code examples are included showing you how to build out an entity, repository and a validator class for a basic blog post.

tagged: introduction integration tutorial laravel orm doctrine2 entity repository validator

Link: http://code.tutsplus.com/tutorials/doctrine-orm-and-laravel-5--cms-24914

Rob Allen:
Validating JSON with ZF2's ZendValidator
Dec 09, 2014 @ 16:42:40

Rob Allen has a quick post today showing how to use the ZendValidator component from Zend Framework 2 to handle JSON validation.

Let's say that you have an admin form where the user can enter JSON and you'd like to validate that the JSON parses before allowing the user to submit. To do this, you can use the rather excellent jsonlint project by Jordi Boggiano. Obviously, add it via Compser.

He starts with a quick example of using the "JsonParser" in isolation to validate a JSON string. Then he integrates it into the framework as a custom validator class (extending the AbstractValidator) and enabling the "isValid" call to be made and return a pass/fail result. You can find out more about the ZendValidator component in this page of the Zend Framework manual.

tagged: zendframework2 json validate jslint custom validator

Link: http://akrabat.com/zend-framework-2/validating-json-with-zf2s-zendvalidator/

SitePoint PHP Blog:
Data Validation in Laravel - Introduction & Custom Validators
Aug 12, 2014 @ 18:59:16

The SitePoint PHP blog has posted the first two parts of a new series looking at how to do data validation in Laravel, a popular PHP framework. Laravel comes with a set of included validators that can easily be used to check incoming data. This article series introduces them and the features they can provide.

If an app was a world then data would be its currency. Every app, no matter what its purpose, deals in data. And almost every type of app works with user input, which means it expects some data from users and acts on it accordingly. But that data needs to be validated to make sure it is of correct type and a user (with nefarious intent) is not trying to break or crack into your app. Which, if you are making an application which requires user input, is why you would need to write code to validate that data as well before you do anything with it.

In the first part of the series they start with an example of doing validation the "old way". They reproduce this same validation using the Laravel validators and show how to introduce it as a service to the overall application. Their "RocketCandy" validation service can then handle the same validations and make for a cleaner interface in the calling script. It's refactored even more to include exceptions when the validation fails and the HTML for outputting the error messages thrown. Unit tests are also included to ensure things are working as they should.

In the second part of the series they build on the examples from part one and introduce custom validators. An example of validation around dashes, spaces and alphanumeric data is included (using regular expressions) and how they can be defined as custom validation rules.

tagged: data validation laravel introduction custom validator framework

Link: http://www.sitepoint.com/series/data-validation-in-laravel-the-right-way/

ServerGrove Blog:
Symfony2 components overview: Validator
Mar 04, 2014 @ 18:55:35

The ServerGrove blog has posted their latest in-depth look at one of the many components that make up the Symfony2 framework. In this latest post they cover the Validator component, another well-used part of the framework.

In the first five posts of this series we have been talking about key components for any PHP framework from the point of view of their internals, such as HttpFoundation to abstract the HTTP protocol, HttpKernel to convert a Request into a Response, Routing to map requests to controllers, EventDispatcher to add reusability and extensibility, and Config to load and validate configuration values. This time we'll delve deeper in the user space to describe a component that is for specific apps rather than just for frameworks. Today's topic will be the Validator component.

They start off talking about a common problem in web applications, running validation on incoming data, and how the component can help. The article then gets into the architecture of the component and provides a simple example of it in use (validating an integer range). They talk about some of the built-in validations, the internationalization support and validation on objects, just just simple values. Finally, there's a look at creating custom validations, their example being a simple check on a given "programming language" string.

tagged: symfony2 component overview validator tutorial

Link: http://blog.servergrove.com/2014/03/03/symfony2-components-overview-validator

Symfony Blog:
Help Symfony reach 3 billion people
Jan 17, 2014 @ 17:53:02

The Symfony project wants your help to allow this popular PHP framework to reach more people all around the world (3 billion, according to them) by helping out with translations in the Validator and Security component.

Internationalization has been one of the pillars of the Symfony success since the very beginning. Besides providing tools to translate both the strings and the contents of your applications, Symfony itself is translated into a lot of different languages. [...] Some of these translations are incomplete or haven't been updated for a long time. For that reason, we are organizing a community initiative to improve the internationalization of Symfony.

The strings they're talking about are in the Validator and Security components and are currently in 20 different languages. They've broken up the ones they're needing help on into a few categories:

  • Completed translations
  • Incomplete translations
  • Unavailable translations
  • Additional translations

Obviously, they'd love ones from any of the last four in that list and they include a few steps on how to grab the latest version of Symfony and get translating.

tagged: symfony project framework translate message validator security

Link: http://symfony.com/blog/help-symfony-reach-3-billion-people

Jeremy Kendall:
PHP Password Hashing: A Dead Simple Implementation
Jan 08, 2014 @ 17:48:23

In this recent post to his site Jeremy Kendall shares some of his thoughts about password hashing and a new library he's written to help make it simpler - event with an existing password hashing method in place.

We all know to encrypt passwords for highest level of security. Unfortunately, too many do it [the wrong way]. While there was never any excuse for getting it that wrong, there’s now no excuse for getting it wrong at all. Developers, meet the new(-ish) PHP password hashing functions (and the userland implementation password-compat).

He shows how to use this password hashing correctly with the "default" hash and how to store that in the database. His Password Validator library aims to help make this even simpler and adds in other features like rehashing and upgrading of legacy passwords. The remainder of the post shows how to use the library for these functions and how to persist them in the tool's storage decorator and interface functionality.

tagged: password hashing implementation validator opensource library

Link: http://jeremykendall.net/2014/01/04/php-password-hashing-a-dead-simple-implementation/

Symfony Blog:
Static Page Caching & Payment Validators in Symfony 2.2
Dec 12, 2012 @ 17:46:39

On the Symfony blog, there's two new posts highlighting some recent improvements to the Symfony2 framework - the addition of static page caching and payment validators:

These features are all a part of the upcoming Symfony 2.2 release that's planned to be moved in the "stabilization" status in early 2013. It should be able two months following that when the stable version will be released.

tagged: symfony framework page caching payment validator

Link:

MaltBlue.com:
Zend Form Mastery with Zend Config - Part 4 Configuring Zend Validators
Jun 05, 2012 @ 16:25:45

On the MaltBlue blog Matt has posted the latest part of the "Zend_Form with Zend_Config" series, part four looking at using and configuring some form validators.

Welcome to the fourth and final part in the Zend Form Mastery with Zend Config series. Previously we looked at the basic form options, element and form wide prefixes, filters and element options. In this installment, we’re going to look at configuring Zend Validators via our XML config. [...] To go in to all of them will take more time than is allowed in the confines of this article. So we’re going to work through 5 of the more interesting and likely used ones.

He covers the validation for: email addresses, postal codes, seeing if a record exists in the database, IBAN validation and checking to see if a value is in an array. He gives XML examples for each of these validation methods including the definitions of options and error/feedback messages.

tagged: zendform zendconfig configure validator tutorial xml

Link:

Henrik Bjørnskov's Blog:
Symfony2: Using the validator symfony1 style
Feb 03, 2012 @ 17:15:01

In this quick new post to his blog Henrik Bjørnskov shows how to use the validators in Symfony2 in a more traditional Symfony 1 style for a form.

Two of the more complicated components in Symfony2 is the Form and Validator component. The Validator is created in such a way it "always" need an Domain Object with Constraints associated through metadata. This is explained in detail here. But there is another way. A way that resemble's the symfony1 forms. Where you could specify the validations directly in your form class.

Code is included in the post to show how to load in a few of the validators (like NotBlank, Email and Choice) and how to use them in the settings defined in the "getDefaultOptions" method.

tagged: symfony2 validator form symfony1 options

Link:

DevShed:
Building Concrete Validators
Dec 22, 2011 @ 17:24:25

On DevShed.com today there's the first part of a two-part series showing how to build self-contained validator objects that can be used to test the format of user input for validity.

In this two-part tutorial, I show why the use of static helper classes can be detrimental to building robust and scalable object-oriented applications in PHP (though you should take into account that the concept is language agnostic). I also implement a set of instantiable, fine-grained validators, which can be easily tested in isolation, injected into the internals of other objects, and so forth.

Their set of "concrete validators" are all based off of a validator interface/abstract class and check things like email formatting, floats, integers and URLs. Also included are a few examples of using the validators in a sample script.

tagged: validator tutorial test data interface abstract class

Link:


Trending Topics: