2017 © Pedro Peláez
 

library urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

image

jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  • Thursday, August 24, 2017
  • by jbroadway
  • Repository
  • 37 Watchers
  • 548 Stars
  • 481,284 Installations
  • PHP
  • 38 Dependents
  • 0 Suggesters
  • 73 Forks
  • 2 Open issues
  • 12 Versions
  • 9 % Grown

The README.md

URLify for PHP

GitHub Workflow Status (branch) Packagist License Packagist Version Packagist PHP Version Support Packagist Downloads, (*1)

A fast PHP slug generator and transliteration library, started as a PHP port of URLify.js from the Django project., (*2)

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()., (*3)

Symbols it cannot transliterate it can omit or replace with a specified character., (*4)

Installation

Install the latest version with:, (*5)

$ composer require jbroadway/urlify

Usage

First, include Composer's autoloader:, (*6)

require_once 'vendor/autoload.php';

To generate slugs for URLs:, (*7)

<?php

echo URLify::slug (' J\'étudie le français ');
// "jetudie-le-francais"

echo URLify::slug ('Lo siento, no hablo español.');
// "lo-siento-no-hablo-espanol"

To generate slugs for file names:, (*8)

<?php

echo URLify::filter ('фото.jpg', 60, "", true);
// "foto.jpg"

To simply transliterate characters:, (*9)

<?php

echo URLify::downcode ('J\'étudie le français');
// "J'etudie le francais"

echo URLify::downcode ('Lo siento, no hablo español.');
// "Lo siento, no hablo espanol."

/* Or use transliterate() alias: */

echo URLify::transliterate ('Lo siento, no hablo español.');
// "Lo siento, no hablo espanol."

To extend the character list:, (*10)

<?php

URLify::add_chars ([
    '¿' => '?', '®' => '(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:, (*11)

<?php

URLify::remove_words (['remove', 'these', 'too']);

To prioritize a certain language map:, (*12)

<?php

echo URLify::filter ('Ägypten und Österreich besitzen wie üblich ein Übermaß an ähnlich öligen Attachés', 60, 'de');
// "aegypten-und-oesterreich-besitzen-wie-ueblich-ein-uebermass-aehnlich-oeligen-attaches"

echo URLify::filter ('Cağaloğlu, çalıştığı, müjde, lazım, mahkûm', 60, 'tr');
// "cagaloglu-calistigi-mujde-lazim-mahkum"

Please note that the "ü" is transliterated to "ue" in the first case, whereas it results in a simple "u" in the latter., (*13)

The Versions

24/08 2017

dev-master

9999999-dev https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

03/01 2017

1.1.0-stable

1.1.0.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

14/09 2016

1.0.9-stable

1.0.9.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

27/07 2016

1.0.8-stable

1.0.8.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

07/12 2015

1.0.7-stable

1.0.7.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

15/10 2015

1.0.6-stable

1.0.6.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

29/05 2015

1.0.5-stable

1.0.5.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

09/03 2015

1.0.4-stable

1.0.4.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

17/03 2014

1.0.3-stable

1.0.3.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

05/02 2014

1.0.2-stable

1.0.2.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

16/10 2013

1.0.1-stable

1.0.1.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate

11/02 2013

1.0.0-stable

1.0.0.0 https://github.com/jbroadway/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

url link encode translit slug urlify transliteration iconv transliterate