ricardofiorani/php-cloudflare-amp-validator

A PHP wrapper for Cloudflare AMP validator

v1.0 2018-09-12 04:26 UTC

README

As Cloudflare announced on https://blog.cloudflare.com/amp-validator-api/, their AMP validator is no longer available.

Well, it was nice while it lasted :)

PHP Cloudflare AMP Validator

Build Status Minimum PHP Version License Total Downloads Coding Standards Scrutinizer Code Quality Code Coverage

PHP Cloudflare AMP Validator is a PHP Library that wraps the Cloudflare AMP validation API.

Requirements

  • PHP >=7.1
  • A PSR-18 HttpClient

Install

Via Composer

$ composer require ricardofiorani/php-cloudflare-amp-validator

Usage

use \RicardoFiorani\Validator\Validator;

$httpClient = new \Your\Psr18\HttpClient();
$requestFactory = new \Your\PSR-17\RequestFactoryInterface; 
$validator = new Validator($httpClient, $requestFactory);
//or you can use the default request factory by ignoring the second parameter 
$validator = new Validator($httpClient);
var_dump($validator->validateUrl('https://amp.mywebsite.com')->isValid());

$content = $yourHtmlRenderer->render();
var_dump($validator->validateContent($content)->isValid());

Testing

$ composer test

Credits

License

The MIT License (MIT). Please see License File for more information.