Download the PHP package ausi/slug-generator without Composer

On this page you can find all versions of the php package ausi/slug-generator. 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 slug-generator

Slug Generator Library

Build Status Coverage Packagist Version Downloads MIT License

This library provides methods to generate slugs for URLs, filenames or any other target that has a limited character set. It’s based on PHPs Transliterator class which uses the data of the CLDR to transform characters between different scripts (e.g. Cyrillic to Latin) or types (e.g. upper- to lower-case or from special characters to ASCII).

Usage

Installation

To install the library use Composer or download the source files from GitHub.

Why create another slug library, aren’t there enough already?

There are many code snippets and some good libraries out there that create slugs, but I didn’t find anything that met my requirements. Options are often very limited which makes it hard to customize for different use cases. Some libs carry large rulesets with them that try to convert characters to ASCII, no one uses Unicode’s CLDR which is the standard for transliteration rules and many other transforms.

But most importantly no library was able to do the “correct” conversions, like Ö-Äpfel to OE-Aepfel for German or İNATÇI to inatçı for Turkish. Because the CLDR transliteration rules are context sensitive they know how to correctly convert to OE-Aepfel instead of Oe-Aepfel or OE-AEpfel. CLDR also takes the language into account and knows that the turkish uppercase letter I has the lowercase form ı instead of i.

Options

All options can be set for the generator object itself new SlugGenerator($options) or overwritten when calling generate($text, $options). Options can by passed as array or as SlugOptions object.

delimiter, default "-"

The delimiter can be any string, it is used to separate words. It gets stripped from the beginning and the end of the slug.

validChars, default "a-z0-9"

Valid characters that are allowed in the slug. The range syntax is the same as in character classes of regular expressions. For example abc, a-z0-9äöüß or \p{Ll}\-_.

ignoreChars, default "\p{Mn}\p{Lm}"

Characters that should be completely removed and not replaced with a delimiter. It uses the same syntax as the validChars option.

locale, default ""

The locale that should be used for the Unicode transformations.

transforms, default Upper, Lower, Latn, ASCII, Upper, Lower

Internally the slug generator uses Transform Rules to convert invalid characters to valid ones. These rules can be customized by setting the transforms, preTransforms or postTransforms options. Usually setting preTransforms is desired as it applies the custom transforms prior to the default ones.

How Transform Rules (like Lower or ASCII) and rule sets (like a > b; c > d;) work is documented on the ICU website: http://userguide.icu-project.org/transforms

Sponsors

Thanks to Blackfire for sponsoring performance profiling tools for this project.


All versions of slug-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1 || ^8.0
ext-intl Version *
ext-mbstring Version *
ext-pcre Version *
lib-icu Version >=4.2.1
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 ausi/slug-generator contains the following files

Loading the files please wait ....