Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

abr4xas/twig-slug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

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

    }
}

Releases

No releases published

Packages

No packages published

Languages