Create Unique Youtube URL's

Create Unique Youtube URL's

Written by Dev Dojo on Jan 23rd, 2018 Views Report Post

Table of contents

Have you ever wanted to create a unique URL like Youtube. The URL usually has a cool unique key with something like:

youtube.com/watch?v=bjT5PJn0Mu8

That looks much better than using the ID of the video:

youtube.com/watch?v=234323

Well, how might you create a URL with a cool unique key that references the actual ID of the video, post, or content you are trying to retrieve from the database. The answer:

Hash IDs

Hash ID's

Hash ID's allow you to create these really cool looking keys that can be encoded and decoded back to the original ID.

There is an official package for creating HASH ID's in your PHP applications here: http://hashids.org/php/

And even better, if you are using Laravel you can use a specific version built just for Laravel here: https://github.com/vinkla/laravel-hashids

In fact there is a specific version of the Hash ID package for Laravel, Codeigniter, Symfony, Kohana, CakePHP, and many others.

So, the next time you need to create some cool HASH ID's for your application be sure to checkout this package.

Comments (0)