Developed with love by KnpLabs Hire us for your project!
20

KnpMarkupValidatorBundle

by KnpLabs

Provide markup validation for your Symfony2 based projects -- THIS PROJECT IS NO LONGER MAINTAINED by KnpLabs

Markup Validator Bundle

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

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

Installation

If you use a deps file, add:

[KnpMarkupValidatorBundle]
    git=http://github.com/KnpLabs/KnpMarkupValidatorBundle.git
    target=/bundles/Knp/Bundle/MarkupValidatorBundle

Or if you want to clone the repo:

git clone git://github.com/KnpLabs/KnpMarkupValidatorBundle.git vendor/bundles/Knp/Bundle/MarkupValidatorBundle

Add the namespace to your autoloader

<?php
// File: app/autoload.php
$loader->registerNamespaces(array(
    'Knp\\Bundle'      => __DIR__.'/../vendor/bundles',
    // ...
));

Add MarkupValidatorBundle to your application kernel

<?php
    // 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
knp_markup_validator:
    default_validator:  default
    validators:
        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

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 validator.w3.org'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.

Copyright (C) 2011 by Knp Labs <hello@knplabs.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • Update composer.json
    By stloyd, 5 years ago
  • Merge pull request #4 from olegstepura/master
    By stloyd, 5 years ago
  • It's markup, not markdown. Not sure if the name should be changed now since it should also be changed on packagist.org
    By Oleg Stepura, 5 years ago
  • Merge pull request #3 from stloyd/composer
    By stloyd, 5 years ago
  • Add composer.json
    By stloyd, 5 years ago
  • Fix case in repo urls
    By lwagner, 5 years ago
  • Merge pull request #2 from kepten/patch-1
    By mbontemps, 5 years ago
  • updated README to include installation steps
    By kepten, 5 years ago
  • Merge pull request #1 from ruian/master
    By mbontemps, 5 years ago
  • Correct in error and warning constructor
    By ruian, 5 years ago
  • Add a phpunit.xml.dist and a bootstrap file
    By mbontemps, 5 years ago
  • Make tests pass
    By mbontemps, 5 years ago
  • Add Bundle to the namespace to follow conventions
    By mbontemps, 5 years ago
  • Change Knplabs to Knp. BC break before Symfony2 release.
    By mbontemps, 5 years ago
  • refactored W3c Processor to handle correctly webservice return value
    By docteurklein, 6 years ago
  • Fix typo in validator
    By Herzult, 6 years ago
  • Fix typo in extension
    By Herzult, 6 years ago
  • Fix extension
    By Herzult, 6 years ago
  • Fix typo in compiler pass
    By Herzult, 6 years ago
  • Update tidy processor to use the tidy extension
    By Herzult, 6 years ago
  • Change validator class
    By Herzult, 6 years ago
  • Remove the need to define a default validator
    By Herzult, 6 years ago
  • Initial commit
    By Herzult, 6 years ago