PHPackages                             kminek/url-id - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. kminek/url-id

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

kminek/url-id
=============

Extract resource IDs (e.g. YouTube video ID) from URLs like a pro!

v1.0.0(6y ago)024MITPHPPHP &gt;=7.3.0

Since May 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/kminek/url-id)[ Packagist](https://packagist.org/packages/kminek/url-id)[ Docs](https://github.com/kminek/url-id)[ RSS](/packages/kminek-url-id/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

 [![Logo](logo.png)](logo.png)

URL-ID
======

[](#url-id)

Extract resource IDs (e.g. YouTube video ID) from URLs like a pro!

Installation
------------

[](#installation)

```
composer require kminek/url-id
```

Usage
-----

[](#usage)

```
use Kminek\UrlId\Parser;

$parser = Parser::createWithDefaultProviders();

$urlId = $parser->parse('https://www.youtube.com/watch?v=9Vqyj77tJfo');

/*
Kminek\UrlId\UrlId {#1
  #id: "9Vqyj77tJfo"
  #resource: "video"
  #provider: "Kminek\UrlId\Provider\Youtube"
}
*/
```

`$urlId` will be `null` if ID cannot be parsed.

Custom providers
----------------

[](#custom-providers)

You can implement your own parsing providers following way:

```
use Kminek\UrlId\Provider\AbstractProvider;

class CustomProvider extends AbstractProvider
{
    /**
     * @return array
     */
    public static function getDomains(): array
    {
        return [
            'sample.com',
        ];
    }

    /**
     * @return array
     */
    public static function getResources(): array
    {
        return [
            UrlIdInterface::RESOURCE_ARTICLE,
        ];
    }

    /**
     * @return string|null
     */
    public function parseArticleResourceId(): ?string
    {
        if (empty($this->path)) {
            return null;
        }

        return $this->path[0];
    }
}

$parser = Parser::createWithDefaultProviders();
$parser->addProvider(CustomProvider::class);

// or
// $parser = new Parser([CustomProvider::class]);

$urlId = $parser->parse('https://sample.com/23');

/*
Kminek\UrlId\UrlId {#1
  #id: "23"
  #resource: "article"
  #provider: "CustomProvider"
}
*/
```

Running unit tests
------------------

[](#running-unit-tests)

```
composer test
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2554d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7c918f54bb848b1ab6ac0f623e0aba72e565865aa15b77b4e7eeba354e38256?d=identicon)[kminek](/maintainers/kminek)

---

Top Contributors

[![kminek](https://avatars.githubusercontent.com/u/373962?v=4)](https://github.com/kminek "kminek (2 commits)")

---

Tags

parserphp-libraryurl

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/kminek-url-id/health.svg)

```
[![Health](https://phpackages.com/badges/kminek-url-id/health.svg)](https://phpackages.com/packages/kminek-url-id)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

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