PHP code example of phil / link-checker

1. Go to this page and download the library: Download phil/link-checker 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/ */

    

phil / link-checker example snippets


use Phil\LinkChecker\ContentLinks;
use Phil\LinkChecker\LinkChecker;
use Phil\LinkChecker\Probe\HttpLinkProbe;
use Phil\Url\Url;

$checker = new LinkChecker(new HttpLinkProbe(), cache: $cache, internalHosts: ['www.example.com']);
$report = $checker->checkContent(new ContentLinks('article-42', Url::fromString('https://www.example.com/news/42'), $html));

echo $report->toText();      // a summary, then one line per link that is not alive
$json = $report->toJson();   // every link, for a screen or an API