2017 © Pedro Peláez
 

library page-analyser

A simple, extendable page analyser written in PHP

image

chrisshennan/page-analyser

A simple, extendable page analyser written in PHP

  • Tuesday, February 27, 2018
  • by chrisshennan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

Page Analyzer

A simple, extensible page analyzer written in PHP., (*1)

Analyzes HTML markup and extracts common attributes such as, (*2)

  • Meta Tags including OpenGraph tags, Twitter Cards etc
  • JSON-LD
  • Apple Icons / favicon
  • Canonical references
  • Response headers
  • RSS / XML feeds (link alternative)

Easily extensible by adding your own custom analyzers., (*3)

Installation

composer require chrisshennan/page-analyzer dev-master

Basic Usage

Analyze a live page, (*4)

Set the list of analyzers when creating the PageAnalyzer., (*5)

$loader = require __DIR__.'/vendor/autoload.php';

$url ='https://shoutabout.it';

$analyzerFactory = new \Cas\PageAnalyzer\Factory\AnalyzerFactory();
$analyzerFactory->addAnalyzerReference('\Cas\PageAnalyzer\Analyzer\MetaData');
$analyzerFactory->addAnalyzerReference('\Cas\PageAnalyzer\Analyzer\Logo');

$analyzerManager = $analyzerFactory->createManager();
$analysisCollection = $analyzerManager->analyze($url)->getAnalysis();

$data = [];

foreach ($analysisCollection as $analyzer => $analysis) {
    $data[$analyzer] = $analysis->getData();
}

...

Custom Analyzers

Create the new analyzer class, (*6)

namespace App\Analyzer;

use Cas\PageAnalyzer\Analyzer\BaseAnalyzer;

class MyCustomAnalyzer extends BaseAnalyzer
{
    public function analyze(string $content) : array
    {
        ...
    }
}

Add the analyzers to the list of analyzers, (*7)

$loader = require __DIR__.'/vendor/autoload.php';

$url ='https://shoutabout.it';

$analyzerFactory = new \Cas\PageAnalyzer\Factory\AnalyzerFactory();
$analyzerFactory->addAnalyzerReference('\Cas\PageAnalyzer\Analyzer\MetaData');
$analyzerFactory->addAnalyzerReference('\Cas\PageAnalyzer\Analyzer\Logo');
$analyzerFactory->addAnalyzerReference('\App\Analyzer\MyCustomAnalyzer');

$analyzerManager = $analyzerFactory->createManager();
$analysisCollection = $analyzerManager->analyze($url)->getAnalysis();

$data = [];

foreach ($analysisCollection as $analyzer => $analysis) {
    $data[$analyzer] = $analysis->getData();
}

...

The Versions

27/02 2018

dev-rework

dev-rework

A simple, extendable page analyser written in PHP

  Sources   Download

MIT

The Requires

 

json-ld schema.org meta tags analyser

24/02 2018

dev-rework-travis

dev-rework-travis

A simple, extendable page analyser written in PHP

  Sources   Download

MIT

The Requires

 

json-ld schema.org meta tags analyser canonical

08/05 2017

dev-master

9999999-dev

A simple, extendable page analyser written in PHP

  Sources   Download

MIT

The Requires

 

json-ld schema.org meta tags analyser