PHP code example of fperdomo / scanner

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

    

fperdomo / scanner example snippets



use Fperdomo\App\Url\Scanner;

$urls = Scanner::create()
->fromArray([
    'https://example.com',
    'https://another-example.com',
])->getInvalidUrls();



use Fperdomo\App\Url\Scanner;

$scanner = Scanner::create()
->fromFile('url.csv')
->onProgress(funtion ($progress) {);
    // show progress
    print_r('');
    print_r('========================================');
    print_r(sprintf('Total URLs processed: %d', $progress->totalRowsProcessed));
    print_r(sprintf(
        'Valid URLs: %d (%.1f%%)',
        $progress->resultsOk,
        $progress->validPercentage()
    ));
    print_r(sprintf(
        'Invalid URLs: %d (%.1f%%)',
        $progress->resultsErr,
        $progress->invalidPercentage()
    ));
    print_r('========================================');
});
Benchmark::dd(fn () => $scanner->scan());


use Fperdomo\App\Url\Scanner;

$urls = Scanner::create()
->fromFile('url.csv')
->field('url')
->chunk(1000)
->onProgress(funtion ($progress) {);
    // show progress
    print_r('');
    print_r('========================================');
    print_r(sprintf('Total URLs processed: %d', $progress->totalRowsProcessed));
    print_r(sprintf(
        'Valid URLs: %d (%.1f%%)',
        $progress->resultsOk,
        $progress->validPercentage()
    ));
    print_r(sprintf(
        'Invalid URLs: %d (%.1f%%)',
        $progress->resultsErr,
        $progress->invalidPercentage()
    ));
    print_r('========================================');
});
Benchmark::dd(fn () => $scanner->scan());