Download the PHP package cocur/slugify without Composer

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


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.

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 slugify


Converts a string into a slug.

Build Status Windows Build status Scrutinizer Quality Score Code Coverage

Latest Release MIT License Total Downloads

Developed by Florian Eckerstorfer in Vienna, Europe with the help of many great contributors.



You can install Slugify through Composer:

Slugify requires the Multibyte String extension from PHP. Typically you can use the configure option --enable-mbstring while compiling PHP. More information can be found in the PHP documentation.

Further steps may be needed for integrations.


Generate a slug:

You can also change the separator used by Slugify:

The library also contains Cocur\Slugify\SlugifyInterface. Use this interface whenever you need to type hint an instance of Slugify.

To add additional transliteration rules you can use the addRule() method.


Many of the transliterations rules used in Slugify are specific to a language. These rules are therefore categorized using rulesets. Rules for the most popular are activated by default in a specific order. You can change which rulesets are activated and the order in which they are activated. The order is important when there are conflicting rules in different languages. For example, in German รค is transliterated with ae, in Turkish the correct transliteration is a. By default the German transliteration is used since German is used more often on the internet. If you want to use prefer the Turkish transliteration you have to possibilities. You can activate it after creating the constructor:

An alternative way would be to pass the rulesets and their order to the constructor.

You can find a list of the available rulesets in Resources/rules.

More options

The constructor takes an options array, you have already seen the rulesets options above. You can also change the regular expression that is used to replace characters with the separator.

(The regular expression used in the example above is the default one.)

By default Slugify will convert the slug to lowercase. If you want to preserve the case of the string you can set the lowercase option to false.

Lowercasing is done before using the regular expression. If you want to keep the lowercasing behavior but your regular expression needs to match uppercase letters, you can set the lowercase_after_regexp option to true.

By default Slugify will use dashes as separators. If you want to use a different default separator, you can set the separator option.

By default Slugify will remove leading and trailing separators before returning the slug. If you do not want the slug to be trimmed you can set the trim option to false.

Changing options on the fly

You can overwrite any of the above options on the fly by passing an options array as second argument to the slugify() method. For example:

You can also modify the separator this way:

You can even activate a custom ruleset without touching the default rules:


We really appreciate if you report bugs and errors in the transliteration, especially if you are a native speaker of the language and question. Feel free to ask for additional languages in the issues, but please note that the maintainer of this repository does not speak all languages. If you can provide a Pull Request with rules for a new language or extend the rules for an existing language that would be amazing.

To add a new language you need to:

  1. Create a [language].json in Resources/rules
  2. If you believe the language should be a default ruleset you can add the language to Cocur\Slugify\Slugify::$options. If you add the language there all existing tests still have to pass
  3. Run php bin/generate-default.php
  4. Add tests for the language in tests/SlugifyTest.php. If the language is in the default ruleset add your test cases to defaultRuleProvider(), otherwise to customRulesProvider().

Submit PR. Thank you very much. ๐Ÿ’š

Code of Conduct

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

The full Code of Conduct can be found here.

This project is no place for hate. If you have any problems please contact Florian: [email protected] โœŒ๐Ÿป๐Ÿณ๏ธโ€๐ŸŒˆ

Further information



Slugify contains a Symfony bundle and service definition that allow you to use it as a service in your Symfony application. The code resides in Cocur\Slugify\Bridge\Symfony\CocurSlugifyBundle and you only need to activate it:

Symfony 2

Support for Symfony 2 has been dropped in Slugify 4.0.0, use cocur/slugify@3.

Symfony 3

Symfony >= 4

You can now use the cocur_slugify service everywhere in your application, for example, in your controller:

The bundle also provides an alias slugify for the cocur_slugify service:

If you use autowire (Symfony >=3.3), you can inject it into your services like this:

Symfony Configuration

You can set the following configuration settings in config.yml (Symfony 2-3) or config/packages/cocur_slugify.yaml (Symfony 4) to adjust the slugify service:


If you use the Symfony framework with Twig you can use the Twig filter slugify in your templates after you have setup Symfony integrations (see above).

If you use Twig outside of the Symfony framework you first need to add the extension to your environment:

To use the Twig filter with TwigBridge for Laravel, you'll need to add the Slugify extension using a closure:

You can find more information about registering extensions in the Twig documentation.


We don't need an additional integration to use Slugify in Mustache.php. If you want to use Slugify in Mustache, just add a helper:


Slugify also provides a service provider to integrate into Laravel (versions 4.1 and later).

In your Laravel project's app/config/app.php file, add the service provider into the "providers" array:

And add the facade into the "aliases" array:

You can then use the Slugify::slugify() method in your controllers:

Zend Framework 2

Slugify can be easely used in Zend Framework 2 applications. Included bridge provides a service and a view helper already registered for you.

Just enable the module in your configuration like this.

After that you can retrieve the Cocur\Slugify\Slugify service (or the slugify alias) and generate a slug.

In your view templates use the slugify helper to generate slugs.

The service (which is also used in the view helper) can be customized by defining this configuration key.

Nette Framework

Slugify contains a Nette extension that allows you to use it as a service in your Nette application. You only need to register it in your config.neon:

You can now use the Cocur\Slugify\SlugifyInterface service everywhere in your application, for example in your presenter:


If you use the Nette Framework with it's native Latte templating engine, you can use the Latte filter slugify in your templates after you have setup Nette extension (see above).

If you use Latte outside of the Nette Framework you first need to add the filter to your engine:

Slim 3

Slugify does not need a specific bridge to work with Slim 3, just add the following configuration:

In a template you can use it like this:


Slugify provides a service provider for use with league/container:

You can configure it by sharing the required options:

You can configure which rule provider to use by sharing it:

Change Log

Version 4.5.1 (16 September 2023)

Version 4.5 (16 September 2023)

Version 4.4.1 (17 September 2023)

Version 4.4 (5 August 2023)

Version 4.3 (7 December 2022)

Version 4.2 (13 August 2022)

Version 4.1 (11 January 2022)

Support for Symfony 6.

Version 4.0 (14 December 2019)

Version 4 does not introduce new major features, but adds support for Symfony 4 and 5, Twig 3 and, most importantly, PHP 7.3 and 7.4.

Support for PHP 5, Twig 1 and Silex is dropped.

Version 3.2 (31 January 2019)

Version 3.1 (22 January 2018)

Version 3.0.1 (24 September 2017)

Version 3.0 (11 August 2017)

Version 2.5 (23 March 2017)

Version 2.4 (9 February 2017)

Version 2.3 (9 August 2016)

Version 2.2 (10 July 2016)

Version 2.1.1 (8 April 2016)

Version 2.1.0 (8 April 2016)

Version 2.0.0 (24 February 2016)

Version 1.4.1 (11 February 2016)

Version 1.4 (29 September 2015)

Version 1.3 (2 September 2015)

Version 1.2 (2 July 2015)

Version 1.1 (18 March 2015)

Version 1.0 (26 November 2014)

No new features or bugfixes, but it's about time to pump Slugify to v1.0.

Version 0.11 (23 November 2014)

Version 0.10.3 (8 November 2014)

Version 0.10.2 (18 October 2014)

Version 0.10.1 (1 September 2014)

Version 0.10.0 (26 August 2014)

Version 0.9 (29 May 2014)

Version 0.8 (18 April 2014)

Version 0.7 (4 April 2014)

This version introduces optional integrations into Symfony2, Silex and Twig. You can still use the library in any other framework. I decided to include these bridges because there exist integrations from other developers, but they use outdated versions of cocur/slugify. Including these small bridge classes in the library makes maintaining them a lot easier for me.

Version 0.6 (2 April 2014)

Version 0.5 (28 March 2014)

Version 0.4.1 (9 March 2014)

Version 0.4 (17 January 2014)

Nearly completely rewritten code, removes iconv support because the underlying library is broken. The code is now better and faster. Many thanks to Marchenko Alexandr.

Version 0.3 (12 January 2014)


Support for Chinese is adapted from jifei/Pinyin with permission.

Slugify is a project of Cocur. You can contact us on Twitter: @cocurco


If you need support you can ask on Twitter (well, only if your question is short) or you can join our chat on Gitter.


In case you want to support the development of Slugify you can help us with providing additional transliterations or inform us if a transliteration is wrong. We would highly appreciate it if you can send us directly a Pull Request on Github. If you have never contributed to a project on Github we are happy to help you. Just ask on Twitter or directly join our Gitter.

You always can help me (Florian, the original developer and maintainer) out by sending me an Euro or two.


The MIT License (MIT)

Copyright (c) 2012-2017 Florian Eckerstorfer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.


All versions of slugify with dependencies

PHP Build Version
Package Version
Requires php Version ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0
ext-mbstring Version *
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 cocur/slugify contains the following files

Loading the files please wait ....