Converts easily a string to a slug.
composer require oukhennicheabdelkrim/slug
<?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
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
.
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