16 Nov, 2019 Root User

Hello, I always found difficulties while working with url specially when it comes to the unicode url, URL also play vital role for the SEO of the website. 

So, to handle the unicode url, I found a excellent package in php: ausi/slug-generator Install the given packages using following command.

composer require ausi/slug-generator

Last part of this tutorials is too add the unique hash at the end of url, we can create hash using md5 function. we are using twelve digit hash so we are truncating the given url to make medium like url. 

function generateUrlFromTitle($title)
    // Generate a 12 digits MD5 slug from Id
    $salt = substr(md5(time()), 0, 12);

    // Slug from title
    $generator  = new SlugGenerator();
    $title = $generator->generate($title);

    // Return Url
    return $title . '-' . $salt;

Profile Image

Prosperous Nepal is possible only from technological innovation.

© 2021, All right reserved.