1. Go to this page and download the library: Download chrisrhymes/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/ */
chrisrhymes / link-checker example snippets
namespace App\Models;
use ChrisRhymes\LinkChecker\Traits\HasBrokenLinks;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasFactory, HasBrokenLinks;
}
use ChrisRhymes\LinkChecker\Jobs\CheckModelForBrokenLinks;
use ChrisRhymes\LinkChecker\Facades\LinkChecker;
$post = Post::first();
// Dispatch the job directly
CheckModelForBrokenLinks::dispatch($post, ['content', 'url']);
// Or using the facade
LinkChecker::checkForBrokenLinks($post, ['content', 'url']);
$post = Post::first();
$post->brokenLinks; // A collection of broken links for the model
$post->brokenLinks[0]->broken_link; // The link that is broken
$post->brokenLinks[0]->exception_message; // The optional exception message
use ChrisRhymes\LinkChecker\Jobs\CheckModelForBrokenLinks;
use ChrisRhymes\LinkChecker\Facades\LinkChecker;
$post = Post::first();
// Dispatch the job directly
CheckModelForBrokenLinks::dispatch($post, ['content', 'url'], 'http://example.com');
// Or using the facade
LinkChecker::checkForBrokenLinks($post, ['content', 'url'], 'http://example.com');