Download the PHP package aakashk-ctpl/laravel-slug without Composer
On this page you can find all versions of the php package aakashk-ctpl/laravel-slug. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aakashk-ctpl/laravel-slug
More information about aakashk-ctpl/laravel-slug
Files in aakashk-ctpl/laravel-slug
Package laravel-slug
Short Description Generate clean, URL-friendly slugs from text in Laravel applications.
License MIT
Homepage https://github.com/aakashk-ctpl/laravel-slug
Informations about the package laravel-slug
Laravel Slug
A small, dependency-light package for generating clean, URL-friendly slugs from text in Laravel applications.
Requirements
- PHP 8.2+
- Laravel 12 or 13
Installation
This package is not yet published on Packagist. Once it is, you'll be able to install it with:
Until then, you can require it locally as a path repository. Add this to your application's composer.json:
then run:
The package's service provider and Slug facade are registered automatically via Laravel's package auto-discovery — no manual setup required.
Basic usage
Use the Slug facade:
Or resolve the underlying service from the container directly:
What it handles
- Lowercases the text
- Replaces spaces and other whitespace with the separator
- Removes/replaces unwanted special characters
- Collapses duplicate separators
- Trims separators from the start and end
- Transliterates common Unicode characters to their closest ASCII equivalent (e.g.
Café→cafe)
Custom separator
Pass a separator as the second argument to override the default for a single call:
Configuration
Publish the config file with the slug-config tag:
This creates config/slug.php:
Change default_separator to set the separator used whenever Slug::make() is called without an explicit one.
Testing
Run the test suite with:
or directly with PHPUnit:
License
The MIT License (MIT). See LICENSE for more information.