Small Twig Slug Generator
Branch: master
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
README.md
composer.json

README.md

Twig Slug Generator

GitHub issues GitHub forks GitHub license

A Twig extension for abr4xas/twig-slug.

how to install

$ composer require abr4xas/twig-slug
$ composer dumpautoload -o // optional

or add this to your composer.json

    "require": {
        "abr4xas/twig-slug": "dev-master"
    }

and

$ composer update
$ composer dumpautoload -o // optional

usage

First register the extension with Twig:

$twig = new Twig_Environment($loader);
$twig->addExtension(new \SeoUrl\SeoUrl());

then use it in your templates:

{{ This is an awesome string | seourl }} // output: this-is-an-awesome-string

in SomeController like this:

<?php

namespace SomeNameSpace;

use SeoUrl\SeoUrl;

class SomeController
{
    public function someFunction()
    {
        $str = 'This is an awesome string';

        $seoUrl = SeoUrl::generateSlug($str); // output: this-is-an-awesome-string

    }
}