Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/emmanuelroecker/php-w3cvalidator

Auto validate html and css files using w3c validation services
https://github.com/emmanuelroecker/php-w3cvalidator

Last synced: 6 days ago
JSON representation

Auto validate html and css files using w3c validation services

Awesome Lists containing this project

README

        

# php-w3cvalidator

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/emmanuelroecker/php-w3cvalidator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/emmanuelroecker/php-w3cvalidator/?branch=master)
[![Build Status](https://travis-ci.org/emmanuelroecker/php-w3cvalidator.svg?branch=master)](https://travis-ci.org/emmanuelroecker/php-w3cvalidator)
[![Coverage Status](https://coveralls.io/repos/emmanuelroecker/php-w3cvalidator/badge.svg?branch=master&service=github)](https://coveralls.io/github/emmanuelroecker/php-w3cvalidator?branch=master)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/66e60d74-1f4c-489e-8d9d-4e5bd78c7cbc/mini.png)](https://insight.sensiolabs.com/projects/66e60d74-1f4c-489e-8d9d-4e5bd78c7cbc)
[![Dependency Status](https://www.versioneye.com/user/projects/5681635ceb4f47003c000896/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/5681635ceb4f47003c000896)

Validate html and css files using [w3c markup validation](http://validator.w3.org/) and [w3c css validation](http://jigsaw.w3.org/css-validator/).

## Installation

This library can be found on [Packagist](https://packagist.org/packages/glicer/w3c-validator).

The recommended way to install is through [composer](http://getcomposer.org).

Edit your `composer.json` and add :

```json
{
"require": {
"glicer/w3c-validator": "dev-master"
}
}
```

Install dependencies :

```bash
php composer.phar install
```

## Example

```php
files()->in(__DIR__ . "/entry/");

//add glicer.css and glicer.html
$files = [$files, __DIR__ . "/glicer.css", __DIR__ . "/glicer.html"];

//return array of reports path in html format or null if ok
$results = $validator->validate(
$files,
['html', 'css'], //validate html and css files
function (SplFileInfo $file) { //callback function
echo $file->getRealpath();
}
);

var_dump($results);
```

$results is an array that associate values to keys :
filename checked => W3C html report or null if no error

In this example,
you can view reports in result/w3c_css_glicer.html, result/w3c_html_glicer.html, result/... from your browser.

## Use html validator offline

Docker must be installed

```bash
docker pull magnetikonline/html5validator
docker run -d -p 8080:80 -p 8888:8888 magnetikonline/html5validator
```

Validator nu Java server on port 8888

Pass url of validator nu to constructor :

```php
$validator = new GlW3CValidator(__DIR__ . "/result","http://127.0.0.1:8888");
```

## Running Tests

You must be online

Launch from command line :

```console
vendor\bin\phpunit
```

## License MIT

## Contact

Authors : Emmanuel ROECKER & Rym BOUCHAGOUR

[Web Development Blog - http://dev.glicer.com](http://dev.glicer.com/)