PHP code example of ricardofiorani / php-cloudflare-amp-validator

1. Go to this page and download the library: Download ricardofiorani/php-cloudflare-amp-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ricardofiorani / php-cloudflare-amp-validator example snippets

 bash
$ composer 
 php
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());