PHPackages                             rottingham/urlvalidator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. rottingham/urlvalidator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

rottingham/urlvalidator
=======================

Validate URL form, Validate Header Existance and Reformat URLs

044PHP

Since Nov 8Pushed 12y ago1 watchersCompare

[ Source](https://github.com/rottingham/UrlValidator)[ Packagist](https://packagist.org/packages/rottingham/urlvalidator)[ RSS](/packages/rottingham-urlvalidator/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

UrlValidator
============

[](#urlvalidator)

Utility Class to validate URL string as well as determine if the URL exists.

For extended usage examples, see test files.

**Composer Ready**

Available on Packagist:

#### Sample Usage

[](#sample-usage)

Simply import the `Urlvalidator.class.php` file into your project if you are not using dependency injection.

```
require __DIR__ . '/src/UrlValidator.class.php';

```

##### Valiate URL

[](#valiate-url)

To validate a URL string, use the `UrlValidator::validate(url)` method;

```
$url = 'http://www.yahoo.com';
$isValid = UrlValidator\UrlValidator::validate($url);
var_dump($isValid);

```

#### Check if URL Exists

[](#check-if-url-exists)

To determine if a URL actaully exists, IE the domain exists and the URL request is not bounced, use the `UrlValidator::exists(url)` method;

```
$url = 'http://www.yahoo.com';
$exists = UrlValidator\UrlValidator::exists($url);
var_dump($exists);

```

**Note:** `UrlValidator::exists(url)` calls `UrlValidator::validate(url)` and will return FALSE if the URL is invalid before every checking the URL headers.

#### Reformat URL

[](#reformat-url)

You can attempt to reformat a bad URL with the `UrlValidator::reformat(url)` method. This method is far from perfect, but since `www.yahoo.com` is technically an invalid URL, it can be quite useful.

```
$url = 'google.com';
$newUrl = UrlValidator\UrlValidator::reformat($url);
var_dump($newUrl);

// Outputs array (size=2)
    'original' => `google.com`
    'url' => 'http://wwww.google.com'

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4079423?v=4)[rottingham](/maintainers/rottingham)[@rottingham](https://github.com/rottingham)

---

Top Contributors

[![rottingham](https://avatars.githubusercontent.com/u/4079423?v=4)](https://github.com/rottingham "rottingham (8 commits)")[![ralphstoys](https://avatars.githubusercontent.com/u/4314053?v=4)](https://github.com/ralphstoys "ralphstoys (2 commits)")

### Embed Badge

![Health badge](/badges/rottingham-urlvalidator/health.svg)

```
[![Health](https://phpackages.com/badges/rottingham-urlvalidator/health.svg)](https://phpackages.com/packages/rottingham-urlvalidator)
```

###  Alternatives

[chaoswey/taiwan-id-validator

台灣身分證、統一編號驗證

319.9k](/packages/chaoswey-taiwan-id-validator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
