PHPackages                             smoren/url-security-manager - 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. smoren/url-security-manager

ActiveLibrary[Security](/categories/security)

smoren/url-security-manager
===========================

Class for building, parsing, signing, signature checking, encrypting and decrypting URLs

1.0.4(5y ago)647811MITPHPPHP &gt;=7.2.0

Since Sep 11Pushed 5y ago2 watchersCompare

[ Source](https://github.com/Smoren/url-security-manager-php)[ Packagist](https://packagist.org/packages/smoren/url-security-manager)[ RSS](/packages/smoren-url-security-manager/feed)WikiDiscussions master Synced today

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

url-security-manager
====================

[](#url-security-manager)

Class for building, parsing, signing, signature checking, encrypting and decrypting URLs.

### Install to your project

[](#install-to-your-project)

```
composer require smoren/url-security-manager
```

### Unit testing

[](#unit-testing)

```
composer install
./vendor/bin/codecept build
./vendor/bin/codecept run unit tests/unit
```

### Demo

[](#demo)

##### Signing

[](#signing)

```
use Smoren\UrlSecurityManager\UrlSecurityManager;

$inputUrl = 'http://localhost:8080/test/path?p1=1&p2=2&p3=3&p4=4';
$secretKey = 'fvd76df89g7fdg89';

// Let's sign some url with our secret key to send signed request to receiver
$usmSender = UrlSecurityManager::parse($inputUrl)
    // signature will be stored as value of query param "sign"
    // only query params from array (2nd argument) will be signed
    ->setSignParams('sign', ['p1', 'p2', 'p3'])
    ->setSecretKey($secretKey) // giving secret key for signing
    ->sign(); // create signature

$signedUrl = $usmSender->stringify();
echo $signedUrl;
// http://localhost:8080/test/path?p1=1&p2=2&p3=3&p4=4&sign=5342af44ed716002a81a2872734729f5

// Now we will try to check the signature of URL:
$usmReceiver = UrlSecurityManager::parse($signedUrl)
    ->setSignParams('sign', ['p1', 'p2', 'p3'])
    ->setSecretKey($secretKey);
$usmReceiver->check(); // will be executed without WrongSignatureException

$usmReceiver
    ->setSignParams('sign', ['p1', 'p2', 'p3'])
    ->setSecretKey('123');
$usmReceiver->check(); // will throw WrongSignatureException

$usmSender = UrlSecurityManager::parse($inputUrl)
    ->setSignParams('sign') // all query params will be signed
    ->setSecretKey($secretKey)
    ->sign();
$signedUrl = $usmSender->stringify();
echo $signedUrl;
// http://localhost:8080/test/path?p1=1&p2=2&p3=3&p4=4&sign=50489186458519f9f141e616dc02af73
```

##### Encrypting/decrypting

[](#encryptingdecrypting)

```
use Smoren\UrlSecurityManager\UrlSecurityManager;

$inputUrl = 'http://localhost:8080/test/path?p1=1&p2=2&p3=3&p4=4';
$secretKey = 'fvd76df89g7fdg89';

// Let's encrypt url with our secret key to send some secret data to receiver:
$usmSender = UrlSecurityManager::parse($inputUrl)
    // encrypted string will be stored as value of query param "encrypted"
    // all query params will be encrypted
    ->setEncryptParams('encrypted')
    ->setSecretKey($secretKey)
    ->encrypt(); // encrypting data

$encryptedUrl = $usmSender->stringify();
echo $encryptedUrl;
// someting like this:
// http://localhost:8080/test/path?encrypted=X4oxVda3u%2FD2NX...

// Now we will try to decrypt received secret data:
$usmReceiver = UrlSecurityManager::parse($encryptedUrl)
    ->setEncryptParams('encrypted')
    ->setSecretKey($secretKey)
    ->decrypt();

$decryptedUrl = $usmReceiver->stringify();
echo $decryptedUrl;
// http://localhost:8080/test/path?p1=1&p2=2&p3=3&p4=4

$usmSender->decrypt();

// encrypt only query params: p1, p2
$usmSender->setEncryptParams('encrypted', ['p1', 'p2']);
$usmSender->encrypt();

echo $usmSender->stringify();
// something like this:
// http://localhost:8080/test/path?p3=3&p4=4&encrypted=CTNdFXZDlBwYwwvQV2L8mGjQg5YydC3...

$usmSender->decrypt();
echo $usmSender->stringify();
// http://localhost:8080/test/path?p3=3&p4=4&p1=1&p2=2
```

##### Building URLs

[](#building-urls)

```
use Smoren\UrlSecurityManager\UrlSecurityManager;

$usm = UrlSecurityManager::create()
    ->setScheme('https')
    ->setHost('test.com')
    ->setPort(8080)
    ->setPath('/test/path')
    ->setParams(['a' => 1, 'b' => 2]);

echo $usm->stringify();
// https://test.com:8080/test/path?a=1&b=2

$usm
    ->setSignParams('sign')
    ->setSecretKey('q1w2e3r4t5y6u7')
    ->sign();

echo $usm->stringify();
// https://test.com:8080/test/path?a=1&b=2&sign=89727a40dc08dc9f12d91b5d6e627c17

$usm = UrlSecurityManager::create([
    'scheme' => 'http',
    'host' => 'test.com',
    'port' => 8080,
    'path' => '/test/path',
    'params' => ['a' => 1, 'b' => 2],
]);

echo $usm->stringify();
// http://test.com:8080/test/path?a=1&b=2
```

##### Parse URL from server request

[](#parse-url-from-server-request)

```
use Smoren\UrlSecurityManager\UrlSecurityManager;

$usm = UrlSecurityManager::parse();

echo $usm->stringify();
// you will see full URL of your current server request
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

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 ~69 days

Total

4

Last Release

1860d ago

### Community

Maintainers

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

---

Top Contributors

[![Smoren](https://avatars.githubusercontent.com/u/7403235?v=4)](https://github.com/Smoren "Smoren (9 commits)")

---

Tags

encryptionsecurityurl-builderurl-parserurlsecuritysignatureencryptdecryptparsingbuilding

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/smoren-url-security-manager/health.svg)

```
[![Health](https://phpackages.com/badges/smoren-url-security-manager/health.svg)](https://phpackages.com/packages/smoren-url-security-manager)
```

###  Alternatives

[phpseclib/phpseclib

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

5.6k434.8M1.3k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[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

961.0M2](/packages/nzo-url-encryptor-bundle)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[ass/xmlsecurity

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

955.6M30](/packages/ass-xmlsecurity)[xxtea/xxtea

XXTEA is a fast and secure encryption algorithm. This is a XXTEA library for PHP.

11341.7k](/packages/xxtea-xxtea)

PHPackages © 2026

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