Converts a string into a slug - Package based on cocur/slugify.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
composer.json
composer.lock
phpunit.xml
readme.md

readme.md

Italomoralesf/Slugify

Converts a string into a slug - Package based on cocur/slugify.

Features

  • Remove special characters
  • You can install in Laravel
  • Does not need external dependence

Installation

You can install using Composer:

$ composer require italomoralesf/slugify

Usage

Generate a slug:

use Italomoralesf\Slugify\Slugify;

$slugify = new Slugify();
echo $slugify->render('Hello World!'); // hello-world

You can also change the separator used by Slugify:

echo $slugify->render('Hello World!', ['separator' => '_']); // hello_world

More options

  • ['regexp' => 'your regular expression']
  • ['separator' => '-']
  • ['lowercase' => true]

Laravel

You can use this package in Laravel.

Register the service provider in app/config/app.php:

'providers' => array(
    "Italomoralesf\Slugify\Bridge\Laravel\SlugifyServiceProvider",
)

And add the facade into the "aliases" array:

'aliases' => array(
    "Slugify" => "Italomoralesf\Slugify\Bridge\Laravel\SlugifyFacade",
)

You can then use the Slugify::render() method in your controllers:

$url = Slugify::render('welcome to the homepage');

Support

Need help? Twitter

You can always help, send me a dollar or two.