1. Go to this page and download the library: Download expstudio/friendly-url library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Expstudio\FriendlyUrl\SluggableInterface;
use Expstudio\FriendlyUrl\SluggableTrait;
class Post extends Eloquent implements SluggableInterface
{
use SluggableTrait;
protected $sluggable = array(
'build_from' => 'title',
'save_to' => 'slug',
);
}
$post = new Post(array(
'title' => 'My Awesome Blog Post'
));
$post->save();
echo $post->slug;
// or, if you don't know the name of the slug attribute:
echo $post->getSlug();