PHPackages                             funcke/dry\_php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. funcke/dry\_php

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

funcke/dry\_php
===============

Dry::Schema and Dry::Validation for php

058PHPCI failing

Since Sep 29Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Funcke/dry_php)[ Packagist](https://packagist.org/packages/funcke/dry_php)[ RSS](/packages/funcke-dry-php/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Dry validation for php [![Build Status](https://camo.githubusercontent.com/fced28970211474041637bf3dd930effaa05d91fb47e7361d76604982f5d6968/68747470733a2f2f7472617669732d63692e6f72672f46756e636b652f6472795f7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Funcke/dry_php)
================================================================================================================================================================================================================================================================================================

[](#dry-validation-for-php-)

A typical PHP app is constantly dealing with a shitload of if-clauses to determine, wether or not an entity is compliant with the constraint the developers had in mind, when creating their software.

Dry offers a simple way to eleminate overhead validation clauses and centers constraints for any type of entity in one file. Just call validate on an instance of this class and it will validate the parameter you provide.

Wether Array or Object Dry::PHP doesn't care
--------------------------------------------

[](#wether-array-or-object-dryphp-doesnt-care)

You may validate an entity multiple times:

- when passed to an endpoint
- before storing in the database
- after deserializing from a file or similiar

With Dry::PHP you just define one single file of constraints and call it on the data. Dry::PHP supports associative arrays in form of \[property =&gt; value\] and standard PHP Objects. The Object itself will be casted to an array during the validation process and then checked.

*be careful: private properties or properties inherited from the parent class will also be included in the checking process!*

Example
-------

[](#example)

```
# ExampleSchema.php
