Converts a string to a slug
1.1.0
2019-02-24 21:00 UTC
Requires
- php: >=5.6.0
Requires (Dev)
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2025-01-25 10:48:47 UTC
README
Converts easily a string to a slug.
1. Install the package via Composer:
composer require oukhennicheabdelkrim/slug
2. Usage
2.1. Simple usage
<?php include 'vendor/autoload.php'; use oukhennicheabdelkrim\slug\Slug; $title = 'my title'; $titleId = 3; $mySlug = Slug::getSlug($title); // my-title $mySlug = Slug::getSlug($title,$titleId); // my-title-3
2.2. Configuration
Configuration was designed to be as flexible as possible,you can change the delimiter and position of id in the configuration class oukhennicheabdelkrim\slug\Conf
.
2.2.1. Example of configuration:
class Conf { /** * string Delimiter */ const DELIMITER = '.'; /** * string position of id (right or left) */ const ID_POSITION = 'left'; }
<?php include 'vendor/autoload.php'; use oukhennicheabdelkrim\slug\Slug; $title = 'my title'; $titleId = 3; $mySlug = Slug::getSlug($title); // my.title $mySlug = Slug::getSlug($title,$titleId); // 3.my.title