Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jbroadway/urlify

A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.
https://github.com/jbroadway/urlify

ascii blogging blogs php pretty-url pretty-urls seo slug slugify slugs transliteration unicode urlify urls

Last synced: 6 days ago
JSON representation

A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

Awesome Lists containing this project

README

        

# URLify for PHP

![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/jbroadway/urlify/ci.yml?branch=master)
![Packagist License](https://img.shields.io/packagist/l/jbroadway/urlify)
![Packagist Version](https://img.shields.io/packagist/v/jbroadway/urlify)
![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/jbroadway/urlify)
![Packagist Downloads](https://img.shields.io/packagist/dt/jbroadway/urlify)

A fast PHP slug generator and transliteration library, started as a PHP port of
[URLify.js](https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/urlify.js)
from the Django project.

Handles symbols from latin languages, Arabic, Azerbaijani, Bulgarian, Burmese, Croatian, Czech, Danish, Esperanto,
Estonian, Finnish, French, Switzerland (French), Austrian (French), Georgian, German, Switzerland (German),
Austrian (German), Greek, Hindi, Kazakh, Latvian, Lithuanian, Norwegian, Persian, Polish, Romanian, Russian, Swedish,
Serbian, Slovak, Turkish, Ukrainian and Vietnamese, and many other via `ASCII::to_transliterate()`.

Symbols it cannot transliterate it can omit or replace with a specified character.

## Installation

Install the latest version with:

```bash
$ composer require jbroadway/urlify
```

## Usage

First, include Composer's autoloader:

```php
require_once 'vendor/autoload.php';
```

To generate slugs for URLs:

```php
'?', '®' => '(r)', '¼' => '1/4',
'½' => '1/2', '¾' => '3/4', '¶' => 'P'
]);

echo URLify::downcode ('¿ ® ¼ ¼ ¾ ¶');
// "? (r) 1/2 1/2 3/4 P"
```

To extend the list of words to remove:

```php