PHP code example of lemaur / php-url-checker

1. Go to this page and download the library: Download lemaur/php-url-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/ */

    

lemaur / php-url-checker example snippets


use Lemaur\UrlChecker\UrlChecker;

$response = UrlChecker::check(
    url: 'https://google.com', 
    userAgent: 'MyApp/1.0 (UrlChecker)',
    connectTimeout: 5,
    timeout: 10,
);
// \Lemaur\UrlChecker\DataTransferObject\CheckData

$response->statusCode;
// (int) 200

$response->reasonPhrase;
// (string) 'OK'

$response->headers:
// (array) ['Date' => ['Sun, 24 Mar 2024 09:06:08 GMT']]

UrlChecker::fake([
    new \GuzzleHttp\Psr7\Response(200),
]);

$response = UrlChecker::check('https://dummy-url.com');

$response->statusCode;
// (int) 200