PHPackages                             wernerdweight/canonicalizer - 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. wernerdweight/canonicalizer

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

wernerdweight/canonicalizer
===========================

Simple PHP string canonicalizer

2.0.1(3y ago)15.7k↓33.3%[1 PRs](https://github.com/wernerdweight/Canonicalizer/pulls)MITPHPPHP &gt;=8.1

Since Jan 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/wernerdweight/Canonicalizer)[ Packagist](https://packagist.org/packages/wernerdweight/canonicalizer)[ Docs](https://github.com/wernerdweight/Canonicalizer)[ RSS](/packages/wernerdweight-canonicalizer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (15)Used By (0)

Canonicalizer
=============

[](#canonicalizer)

Simple PHP string canonicalizer

[![Build Status](https://camo.githubusercontent.com/4d93351dc59563bfe8fcaa6bfacc8b28ea170eef041d53ffef6236e480d6843e/68747470733a2f2f6170702e7472617669732d63692e636f6d2f7765726e6572647765696768742f43616e6f6e6963616c697a65722e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/wernerdweight/Canonicalizer)[![Latest Stable Version](https://camo.githubusercontent.com/78d01793d0a56d463dc21b1c218b24b64df346a485c2e4df41ebde3a2bcbb531/68747470733a2f2f706f7365722e707567782e6f72672f7765726e6572647765696768742f63616e6f6e6963616c697a65722f762f737461626c65)](https://packagist.org/packages/wernerdweight/canonicalizer)[![Total Downloads](https://camo.githubusercontent.com/7e100fb5965b13020bd03051948f2f7e18826636d581fb96463786abf5c666b0/68747470733a2f2f706f7365722e707567782e6f72672f7765726e6572647765696768742f63616e6f6e6963616c697a65722f646f776e6c6f616473)](https://packagist.org/packages/wernerdweight/canonicalizer)[![License](https://camo.githubusercontent.com/42c4201e8270097e2caa73d58a2171622a5e58ec5466a1aee10255704627a621/68747470733a2f2f706f7365722e707567782e6f72672f7765726e6572647765696768742f63616e6f6e6963616c697a65722f6c6963656e7365)](https://packagist.org/packages/wernerdweight/canonicalizer)

Instalation
-----------

[](#instalation)

1. Download using composer

```
composer require wernerdweight/canonicalizer
```

2. Use in your project

```
use WernerDweight\Canonicalizer\Canonicalizer;

$string = 'This is an interesteing string with some strange cháračtěřš in it. Хорошо?'
$maxLength = 255;   // maximal resulting canonical length (excessive chars will be trimmed)

$canonicalizer = new Canonicalizer($maxLength);
$canonical = $canonicalizer->canonicalize($string);

echo $canonical;    // this-is-an-interesting-string-with-some-strange-characters-in-it-choroso
```

API
---

[](#api)

- **`canonicalize(string $string[, string $ending[, string $separator]]): string`** \\

    - `$string` - string to be canonicalized,
    - `$ending` - string to be appended at the end of canonicalized string (ending is included in `$maxLength`) - useful to append ids, file formats etc.; default `''` (empty string),
    - `$separator` - string used to separate canonicalized words; default `-` (dash).
- **`setBeforeCallback(?callable): self`**
    Allows to set a callback function that will be called **before** the given string is canonicalized.
    The callback should respenct this definition `function (string): string`.
    **Warning:** the callback remains in place until explicitly nulled (`$canonicalizer->setBeforeCallback(null)`).
- **`setAfterCallback(?callebld): self`**Allows to set a callback function that will be called **after** the given string is canonicalized. The callback should respenct this definition `function (string): string`. **Warning:** the callback remains in place until explicitly nulled (`$canonicalizer->setAfterCallback(null)`).

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity77

Established project with proven stability

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

Recently: every ~293 days

Total

13

Last Release

1182d ago

Major Versions

1.3.0 → 2.0.02023-02-21

PHP version history (3 changes)v1.0.0PHP &gt;=7.1.0

1.1.2PHP &gt;=7.2.0

2.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b1454d4a92d76c33018ef518335ec921cf3eadbe591437c47622510f465c9ed?d=identicon)[wernerdweight](/maintainers/wernerdweight)

---

Top Contributors

[![wernerdweight](https://avatars.githubusercontent.com/u/2445436?v=4)](https://github.com/wernerdweight "wernerdweight (14 commits)")

---

Tags

randomgeneratortoken

### Embed Badge

![Health badge](/badges/wernerdweight-canonicalizer/health.svg)

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

###  Alternatives

[mistic100/randomcolor

Generate attractive random colors

2431.4M6](/packages/mistic100-randomcolor)[ihor/nspl

Non-standard PHP library (NSPL) - functional primitives toolbox and more

381368.5k](/packages/ihor-nspl)[nubs/random-name-generator

A library to create interesting, sometimes entertaining, random names.

135680.2k3](/packages/nubs-random-name-generator)[gladcodes/keygen

A fluent PHP random key generator.

119668.9k2](/packages/gladcodes-keygen)[markrogoyski/itertools-php

Iteration tools for PHP

14911.3k](/packages/markrogoyski-itertools-php)[delight-im/random

The most convenient way to securely generate anything random in PHP

2345.4k](/packages/delight-im-random)

PHPackages © 2026

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