urlify 0,2,0,0 travis-ci Packagist phpunit

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

URLify for PHP

A PHP port of URLify.js from the Django project. Handles symbols from Latin languages as well as Arabic, Azerbaijani, Czech, German, Greek, Latvian, Lithuanian, Persian, Polish, Romanian, Bulgarian, Russian, Serbian, Turkish, Ukrainian and Vietnamese. Symbols it cannot transliterate it will simply omit.

Usage:

To generate slugs for URLs:

<?php

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

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

?>

To generate slugs for file names:

<?php

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

?>

To simply transliterate characters:

<?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:

<?php

URLify::add_chars (array (
	'¿' => '?', '®' => '(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

URLify::remove_words (array ('remove', 'these', 'too'));

?>

To prioritize a certain language map:

<?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.

Related Repositories

urlify

urlify

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

node-urlify

node-urlify

simplifies converting utf8 strings to ASCII strings which can be used as readable URL-segments. ...

Angular-Urlify

Angular-Urlify

Filter to create better seo urls and slugs with angularjs ...

angular-urlify

angular-urlify

Filter to create better seo urls and slugs with angularjs ...

django-urlify

django-urlify

django-urlify node wrapper for rapid installation ...


Top Contributors

jbroadway geminorum nickl- GrahamCampbell mkraemer patrickheck KorvinSzanto jmontoyaa karptonite bamse16 nikmarchenko mente ywarnier rinogo shefi skyosev quangbahoa hkdobrev mlocati tobiassjosten TomasVotruba Nayjest andgrankin plaker

Dependencies

package version
php >=5.3.0

Releases

-   1.0.9-stable zip tar
-   1.0.8-stable zip tar
-   1.0.7-stable zip tar
-   1.0.6-stable zip tar
-   1.0.5-stable zip tar
-   1.0.4-stable zip tar
-   1.0.3-stable zip tar
-   1.0.2-stable zip tar
-   1.0.1-stable zip tar
-   1.0.0-stable zip tar