This package is abandoned and no longer maintained. No replacement package was suggested.

Provide markup validation for your Symfony2 based projects.

dev-master 2012-03-11 00:28 UTC

This package is auto-updated.

Last update: 2022-09-23 13:39:33 UTC


Bundle that provides markup validation functionality to your Symfony2 based projects.

This bundle is in early development state, so any contribution is welcome! ;)


If you use a deps file, add:


Or if you want to clone the repo:

git clone git:// vendor/bundles/Knp/Bundle/MarkupValidatorBundle

Add the namespace to your autoloader

// File: app/autoload.php
    'Knp\\Bundle'      => __DIR__.'/../vendor/bundles',
    // ...

Add MarkupValidatorBundle to your application kernel

    // File: app/AppKernel.php
    public function registerBundles()
        return array(
            // ...
            new Knp\Bundle\MarkupValidatorBundle\KnpMarkupValidatorBundle(),
            // ...

Define validators

The first step, after the bundle is installed in your project, is to define validators in your application configuration:

# app/config/config.yml
    default_validator:  default
            processor:  tidy

It tells to the markup validator extension to create a validator service named markup_validator.default_validator using the tidy processor.

The default_validator tells the extension to create the markup_validator service which is an alias for the markup_validator.default_validator one.

You can define as many validators as you want.


Processors are used by the validator to validate the markup. They are responsible to return an array of warning and error messages.

The bundle provides two processors:

  • w3c which uses the's api
  • tidy which uses the tidy binary

If you want to define your own validator, you simply need to create a service implementing the Knp\Bundle\MarkupValidatorBundle\Validation\ProcessorInterface with the markup_validator.processor tag and its name as alias tag attribute. The extension will create a service for each validator named as follow: markup_validator.{{ alias }}_processor.