Library that offers Input Filtering based on Annotations for use with Objects. Check out for 2.0 pre-release.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src/DMS/Filter Merge branch 'php7-compat' of into php7-… Feb 28, 2016
tests/DMS Applied fixes from StyleCI Feb 28, 2016
.gitignore Removing vendor folder that sneaked in Jan 14, 2014
.travis.yml Speeding up travis. Feb 28, 2016 Tweaks and Changelog Feb 28, 2016
LICENSE Update Mar 1, 2016
composer.json Avoiding bad versions of ZF stdlib Feb 28, 2016
composer.lock Avoiding bad versions of ZF stdlib Feb 28, 2016
phpunit.xml Fixed directory structure Jan 14, 2014

DMS Filter Component

This library provides a service that can be used to filter object values based on annotations

Latest Stable Version Total Downloads Latest Unstable Version License SensioLabsInsight Build Status


Use composer to add DMS\Filter to your app

composer require dms/dms-filter


Your Entity:


namespace App\Entity;

//Import Annotations
use DMS\Filter\Rules as Filter;

class User

    * @Filter\StripTags()
    * @Filter\Trim()
    * @Filter\StripNewlines()
    * @var string
    public $name;

    * @Filter\StripTags()
    * @Filter\Trim()
    * @Filter\StripNewlines()
    * @var string
    public $email;



    //Get Doctrine Reader
    $reader = new Annotations\AnnotationReader();

    //Load AnnotationLoader
    $loader = new Mapping\Loader\AnnotationLoader($reader);
    $this->loader = $loader;

    //Get a MetadataFactory
    $metadataFactory = new Mapping\ClassMetadataFactory($loader);

    //Get a Filter
    $filter = new DMS\Filter\Filter($metadataFactory);

    //Get your Entity
    $user = new App\Entity\User();
    $user->name = "My <b>name</b>";
    $user->email = "";

    //Filter you entity

    echo $user->name; //"My name"
    echo $user->email; //""

Full example:


This package relies on these external libraries:

  • Doctrine Annotations


Feel free to send pull requests, just follow these guides:

  • Fork
  • Code
  • Test
    • Just create FilterTestCase and run phpunit
  • Submit PR


This library is inspired by the Symfony 2 Validator component and is meant to work alongside it.

Symfony 2 Validator: