PHPackages                             kamranahmedse/php-shorthand - 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. kamranahmedse/php-shorthand

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

kamranahmedse/php-shorthand
===========================

Calculate the set of unique abbreviations for a given set of strings.

1.0.1(9y ago)261135MITPHP

Since Sep 21Pushed 7y ago2 watchersCompare

[ Source](https://github.com/kamranahmedse/php-shorthand)[ Packagist](https://packagist.org/packages/kamranahmedse/php-shorthand)[ Docs](https://github.com/kamranahmedse/php-abbrev)[ RSS](/packages/kamranahmedse-php-shorthand/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

php-shorthand
=============

[](#php-shorthand)

[![Build Status](https://camo.githubusercontent.com/f6cf12ce566aa0367801ee3848ddb81bfbc0e3c7518b1ede02cd6fd065914a29/68747470733a2f2f7472617669732d63692e6f72672f6b616d72616e61686d656473652f7068702d73686f727468616e642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kamranahmedse/php-shorthand)[![Code Coverage](https://camo.githubusercontent.com/b19c7c40c507fa32a98814a32885489ebe4042549200264547d1d32b5834c21f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6b616d72616e61686d656473652f7068702d73686f727468616e642e7376673f6d61784167653d32353932303030)](https://scrutinizer-ci.com/g/kamranahmedse/php-shorthand/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/3dc4b6a9a5a12a308fca05ff886e253ac98982cbfc3c108aec5be7d02cd32696/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b616d72616e61686d656473652f7068702d73686f727468616e642e7376673f6d61784167653d32353932303030)](https://packagist.org/packages/kamranahmedse/php-shorthand)

> Calculate unique shorthands for a given set of strings

Inspired by [ruby's abbrev](http://apidock.com/ruby/Abbrev) module, it let's you calculate the unique set of shorthands for the given set of words.

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

[](#installation)

Use the following command to install via composer

```
composer require kamranahmedse/php-shorthand

```

For further details you can find the package at [Packagist](https://packagist.org/packages/kamranahmedse/php-shorthand).

Usage
-----

[](#usage)

Instantiate the `Shorthand` class while passing the words for which you want the shorthands

```
// Introduce the class into your scope
use KamranAhmed\Shorthand\Shorthand;

$shorthand = new Shorthand([
    'crore',
    'create',
]);

$shorthands = $shorthand->generate();
```

It will return an associative array with the key set to the shorthand keyword and value set to the actual word that it refers to

```
// Shorthands for the above example
[
    'cre'    => 'create',
    'crea'   => 'create',
    'creat'  => 'create',
    'create' => 'create',
    'cro'    => 'crore',
    'cror'   => 'crore',
    'crore'  => 'crore',
],
```

Usage Scenarios
---------------

[](#usage-scenarios)

It can come quite handy when writing command line script that takes a number of options and the user may enter the options shorthand or maybe other cases where you want to be able to accept shorthands.

For example, in a script that accepts the options `['delete', 'create', 'update']`, in your script, it can let you infer from the option that user wanted even when they typed a shorthand as long as it is unambiguous

```
$ shorthand cr   # create
$ shorthand d    # delete
$ shorthand upd  # update
```

Contribution
------------

[](#contribution)

Feel free to fork, enhance, open issues, create pull requests or spread the word.

License
-------

[](#license)

MIT © [Kamran Ahmed](http://kamranahmed.info)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 95.8% 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 ~0 days

Total

2

Last Release

3569d ago

### Community

Maintainers

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

---

Top Contributors

[![nilbuild](https://avatars.githubusercontent.com/u/4921183?v=4)](https://github.com/nilbuild "nilbuild (23 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

abbreviationsshorthandabbrevruby-abbrevphp-abbrevphp-shorthand

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kamranahmedse-php-shorthand/health.svg)

```
[![Health](https://phpackages.com/badges/kamranahmedse-php-shorthand/health.svg)](https://phpackages.com/packages/kamranahmedse-php-shorthand)
```

###  Alternatives

[simivar/reverse-print-r

Library to reverse print\_r output to PHP objects, arrays and scalar values.

151.1k](/packages/simivar-reverse-print-r)

PHPackages © 2026

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