Download the PHP package pugx/shortid-php without Composer

On this page you can find all versions of the php package pugx/shortid-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package shortid-php

ShortId

Latest Stable Version Total Downloads PHP Version Require Build Status Code Climate Test Coverage codecov License

This library is an implementation of ShortId for PHP.

Installation

Install the library via Composer:

Usage

ShortId is a PHP library that generates short, unique, and random strings. It's useful in scenarios where you need concise identifiers, such as URL shortening or generating unique keys.

Basic usage

Just call PUGX\Shortid\Shortid::generate() to get a random string with default length 7, like "MfiYIvI".

Advanced usage

For more control, you can customize the alphabet and length using the Factory class.

The default alphabet uses all letters (lowercase and uppercase), all numbers, underscore, and hyphen.

As an alternative, you can customize single generations:

More readable strings

Sometimes, you want to avoid some ambiguous characters, like B/8 or I/l (uppercase/lowercase). In this case, you can pass a third parameter true to the generate method. Notice that in this case the alphabet will be ignored, so it makes sense to pass a null one.

Example:

Pre-defined values

If you need a deterministic string, instead of a random one, you can call directly the class constructor. This could be useful, for instance, when you need pre-defined data for testing purposes.

Doctrine

If you want to use ShortId with Doctrine ORM, take a look at ShortId Doctrine type.

Doctrine and Symfony

If you want to use ShortId with Doctrine ORM and Symfony framework, take a look to ShortId Doctrine type bundle.

Dependencies replacement

This library uses a polyfill, so it can be used in environments where the mbstring native extension is not available.

If, instead, your environment is offering that extension, you can avoid installing that polyfill by configuring a replace entry in your composer.json.

The same applies to the randomLib library: if you are using PHP 8.3 or higher, you can replace it, since this library uses the native Random class instead.

Contributing

Contributions are welcome. Feel free to open a Pull Request or file an issue here on GitHub! Please read the contributing guidelines first.


All versions of shortid-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
paragonie/random-lib Version ^2.0
symfony/polyfill-mbstring Version ^1.19
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pugx/shortid-php contains the following files

Loading the files please wait ....