PHPackages                             patieru/url-signer - 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. [Security](/categories/security)
4. /
5. patieru/url-signer

ActiveLibrary[Security](/categories/security)

patieru/url-signer
==================

Generate a url with an expiration date and signature to prevent unauthorized access

0.0.4(6y ago)1231MITPHPPHP &gt;=7.2

Since Sep 27Pushed 6y ago1 watchersCompare

[ Source](https://github.com/patieru12/url-signer)[ Packagist](https://packagist.org/packages/patieru/url-signer)[ Docs](https://github.com/patieru12/url-signer)[ RSS](/packages/patieru-url-signer/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (1)

This package can create URLs with a limited lifetime. This is done by adding an expiration date and a signature to the URL.

```
$urlSigner = new MD5UrlSigner('randomkey');

$urlSigner->sign('https://myapp.com', 30);

// => The generated url will be valid for 30 days
```

This will output an URL that looks like `https://myapp.com/?expires=xxxx&signature=xxxx`.

Imagine mailing this URL out to the users of your application. When a user clicks on a signed URL your application can validate it with:

```
$urlSigner->validate('https://myapp.com/?expires=xxxx&signature=xxxx');
```

Install
-------

[](#install)

The package can installed via Composer:

```
$ composer require patieru/url-signer

```

Usage
-----

[](#usage)

A signer-object can sign URLs and validate signed URLs. A secret key is used to generate signatures.

```
use Patieru\UrlSigner\MD5UrlSigner;

$urlSigner = new MD5UrlSigner('mysecretkey');
```

### Generating URLs

[](#generating-urls)

Signed URLs can be generated by providing a regular URL and an expiration date to the `sign` method.

```
$expirationDate = (new DateTime)->modify('10 days');

$urlSigner->sign('https://myapp.com', $expirationDate);

// => The generated url will be valid for 10 days
```

If an integer is provided as expiration date, the url will be valid for that amount of days.

```
$urlSigner->sign('https://myapp.com', 30);

// => The generated url will be valid for 30 days
```

### Validating URLs

[](#validating-urls)

To validate a signed URL, simply call the `validate()` method. This will return a boolean.

```
$urlSigner->validate('https://myapp.com/?expires=1439223344&signature=2d42f65bd023362c6b61f7432705d811');

// => true

$urlSigner->validate('https://myapp.com/?expires=1439223344&signature=2d42f65bd0-INVALID-23362c6b61f7432705d811');

// => false
```

Writing custom signers
----------------------

[](#writing-custom-signers)

This packages provides a signer that uses md5 to generate signature. You can create your own signer by implementing the `Patieru\UrlSigner\UrlSigner`-interface. If you let your signer extend `Patieru\UrlSigner\BaseUrlSigner` you'll only need to provide the `createSignature`-method.

Tests
-----

[](#tests)

The tests can be run with:

```
$ vendor/bin/phpspec run

```

\##Integrations To get started quickly in Laravel you can use the [patieru/laravel-url-signer](https://github.com/patieru12/laravel-url-signer) package.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Ruberandinda Patience](https://github.com/patieru12)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

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

Every ~2 days

Total

4

Last Release

2458d ago

PHP version history (2 changes)0.0.1PHP &gt;=7.0.13

0.0.3PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29778225?v=4)[Ruberandinda Patience](/maintainers/patieru12)[@patieru12](https://github.com/patieru12)

---

Top Contributors

[![patieru12](https://avatars.githubusercontent.com/u/29778225?v=4)](https://github.com/patieru12 "patieru12 (5 commits)")

---

Tags

urlsecurityencryptionsignpatieru

### Embed Badge

![Health badge](/badges/patieru-url-signer/health.svg)

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

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k455.2M1.5k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k170.7M239](/packages/defuse-php-encryption)[tilleuls/url-signer-bundle

Create and validate signed URLs with a limited lifetime in Symfony

81357.6k](/packages/tilleuls-url-signer-bundle)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4432.4M16](/packages/spatie-url-signer)[nzo/url-encryptor-bundle

The NzoUrlEncryptorBundle is a Symfony Bundle used to Encrypt and Decrypt data and variables in the Web application or passed through URL

951.1M2](/packages/nzo-url-encryptor-bundle)[ass/xmlsecurity

The XmlSecurity library is written in PHP for working with XML Encryption and Signatures

955.6M33](/packages/ass-xmlsecurity)

PHPackages © 2026

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