PHP code example of mdooley47 / laravel-urlvalidator

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

    

mdooley47 / laravel-urlvalidator example snippets


\MDooley47\UrlValidator\UrlValidator::match(
    'https://user:[email protected]/path?query=true#fragment',
    [
        'scheme' => 'https',
        'user' => 'user',
        'pass' => 'pass',
        'subdomain' => 'sub',
        'domain' => 'domain',
        'tld' => 'tld',
        'path' => '/path',
        'query' => 'query=true',
        'fragment' => 'fragment',
        'host' => 'sub.domain.tld',
    ]);
// Returns Validator->passes()

// You can pass a string in place of the $options array.
// This will default to using the host validator.
// Since we use Str::is, that means we can match a pattern.
\MDooley47\UrlValidator\UrlValidator::match(
    'https://user:[email protected]/path?query=true#fragment',
    'sub.*.tld'
    );

\Illuminate\Support\Facades\Validator::make(
    [
        'url' => 'https://user:[email protected]/path?query=true#fragment'
    ],
    [
        'url' => '