PHPackages                             horde/service\_urlshortener - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. horde/service\_urlshortener

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

horde/service\_urlshortener
===========================

URL shortening library

v3.0.0alpha4(3mo ago)102LGPL-2.1-onlyPHPPHP ^8.1

Since Jan 9Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/horde/Service_UrlShortener)[ Packagist](https://packagist.org/packages/horde/service_urlshortener)[ Docs](https://www.horde.org/libraries/Horde_Service_UrlShortener)[ RSS](/packages/horde-service-urlshortener/feed)WikiDiscussions FRAMEWORK\_6\_0 Synced today

READMEChangelog (1)Dependencies (5)Versions (7)Used By (0)

Horde Service\_UrlShortener
===========================

[](#horde-service_urlshortener)

Modern PHP library for URL shortening services with native PSR-7/PSR-17/PSR-18 support.

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

[](#installation)

```
composer require horde/service-urlshortener
```

Requirements
------------

[](#requirements)

- PHP 8.1+
- PSR-18 HTTP client implementation
- PSR-17 HTTP factory implementation

Quick Start
-----------

[](#quick-start)

```
use Horde\Service\UrlShortener\TinyUrl;
use Horde\Service\UrlShortener\ValueObject\LongUrl;

// Simple facade API
$shortener = new TinyUrl($httpClient, $requestFactory);
$shortUrl = $shortener->shorten('https://www.example.com/very/long/url');
echo $shortUrl; // https://tinyurl.com/abc123

// Rich domain API with metadata
$longUrl = LongUrl::fromString('https://www.example.com/very/long/url');
$result = $shortener->shortenWithMetadata($longUrl);

echo $result->getShortUrl()->toString();
echo "Saved: {$result->getPercentageSaved()}%";
echo "Reduction: {$result->getLengthReduction()} characters";
```

Configuration
-------------

[](#configuration)

```
use Horde\Service\UrlShortener\ValueObject\ShortenerConfig;

$config = ShortenerConfig::default()
    ->withTimeout(30)
    ->withCustomAlias('myalias')
    ->withExpiration(14); // days

$shortener = new TinyUrl($httpClient, $requestFactory, $config);
```

Architecture
------------

[](#architecture)

This library provides two API levels for progressive disclosure:

### Facade API

[](#facade-api)

Simple string-based interface for basic usage:

```
shorten(string|UriInterface $url): string
```

### Domain API

[](#domain-api)

Rich value objects with detailed metadata:

```
shortenWithMetadata(LongUrl $url): ShorteningResult
```

Value Objects
-------------

[](#value-objects)

- **LongUrl** - Input URL with validation and parsing
- **ShortUrl** - Output short URL with service metadata
- **ShorteningResult** - Complete result with metrics (length reduction, expiration, etc.)
- **ShortenerConfig** - Immutable configuration with fluent interface

Supported Services
------------------

[](#supported-services)

- TinyURL (built-in)
- Extensible via `UrlShortenerInterface`

Exception Handling
------------------

[](#exception-handling)

```
use Horde\Service\UrlShortener\UrlShortenerException;

try {
    $shortUrl = $shortener->shorten($longUrl);
} catch (UrlShortenerException $e) {
    // Handle shortening failures
}
```

Legacy Support
--------------

[](#legacy-support)

The PSR-0 `lib/` directory provides backward compatibility wrappers for Horde 5 applications. New code should use the modern `Horde\Service\UrlShortener` namespace.

Documentation
-------------

[](#documentation)

- [UPGRADING.md](doc/UPGRADING.md) - Migration guide from Horde 5
- [API Documentation](https://dev.horde.org/)

License
-------

[](#license)

LGPL 2.1 - See LICENSE file for details.

Contributing
------------

[](#contributing)

Contributions are welcome! Please follow:

- PHP 8.2+ with strict types
- PER-1 coding style
- Comprehensive unit tests
- Conventional Commits for commit messages

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance85

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

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

Every ~1358 days

Total

4

Last Release

118d ago

Major Versions

2.0.3 → v3.0.0alpha12021-07-04

PHP version history (4 changes)2.0.2PHP &gt;=5.3.0,&lt;=6.0.0alpha1

2.0.3PHP ^5.3 || ^7

v3.0.0alpha1PHP ^7

v3.0.0alpha4PHP ^8.1

### Community

Maintainers

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

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

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

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

![](https://www.gravatar.com/avatar/816e2b926f25f8cd2939054c7a7173011b4303d690e25ab61bf33cf8c7cf71ae?d=identicon)[tdannhauer](/maintainers/tdannhauer)

---

Top Contributors

[![yunosh](https://avatars.githubusercontent.com/u/379318?v=4)](https://github.com/yunosh "yunosh (53 commits)")[![mrubinsk](https://avatars.githubusercontent.com/u/66822?v=4)](https://github.com/mrubinsk "mrubinsk (7 commits)")[![ralflang](https://avatars.githubusercontent.com/u/646976?v=4)](https://github.com/ralflang "ralflang (6 commits)")[![slusarz](https://avatars.githubusercontent.com/u/381003?v=4)](https://github.com/slusarz "slusarz (2 commits)")

### Embed Badge

![Health badge](/badges/horde-service-urlshortener/health.svg)

```
[![Health](https://phpackages.com/badges/horde-service-urlshortener/health.svg)](https://phpackages.com/packages/horde-service-urlshortener)
```

###  Alternatives

[horde/horde

Horde base application

583.0k70](/packages/horde-horde)[horde/kronolith

Calendar and scheduling application

101.5k5](/packages/horde-kronolith)[horde/imp

Webmail application

261.3k](/packages/horde-imp)

PHPackages © 2026

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