Symfony2 “urlize”

I have often missed the


 method from Doctrine1 in Symfony2 with Doctrine2.

Of course there’s the doctrine extensions with the sluggable behaviour, but sometimes it seems a bit overhead for smaller tasks.

I just recently discovered Behat Transliterator, which brings just the dearly missed urlize function back.

Just do

composer require behat/transliterator

As it’s an abstract class, you’ll have to create your own Helper class extending it.

And there you go:

MyTextHelper::urlize("how great is that?")

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.