Download the PHP package ballen/sluginator without Composer
On this page you can find all versions of the php package ballen/sluginator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sluginator
Sluginator
A URL slug creation and sanitisation library for PHP, simply feed it a string (such as a blog title) and it will create a URL friendly slug.
Requirements
This library is unit tested against PHP 7.3, 7.4, 8.0, 8.1 and 8.2!
If you need to use an older version of PHP, you should instead install the 2.x version of this library (see below for details).
License
This client library is released under the MIT license, a copy of the license is provided in this package.
Setup
I highly recommend the use of Composer when installing and using this library, it is not mandatory however and you can use a provided 'include' script to load in this library if required.
Composer
Add the latest version of Sluginator to your project by running:
If you need to use an older version of PHP, version 1.x.x supports PHP 5.6, 7.0, 7.1 and 7.2, you can install this version using Composer with this command instead:
Standalone
You can use the library "standalone" by downloading it from the GitHub releases section, extracting the files to a place on your server and then adding the "include" into your code like so:
Examples
The output will be my-awesomely-wickid-example-title
.
The library also contains other useful methods to enable you to:
- Specify characters of which should be removed from the string, by default a healthy set of non-url characters are removed.
- Specify a different space replacement character (by default this is a hyphen '-').
- Output the slug with or without URL encoding (disabled by default as not required).
- Force output as all lowercase character (default is 'true').
Here is an example using a few extra settings:
In the above example we have request that the slug character case remains untouched and instead of splitting spaces with a hyphen (-) we will instead replace them with underscore characters (_) instead.
Tests and coverage
This library is fully unit tested using PHPUnit.
I use GitHub Actions for continuous integration, which triggers the unit tests each time a commit is pushed.
If you wish to run the tests yourself you should run the following:
Code coverage can also be ran but requires XDebug installed...
Support
I am happy to provide support via. my personal email address, so if you need a hand drop me an email at: [[email protected]]().