article title to url slug with cakephp

If you are using cakephp framework for your web application development. Sometimes you need to create SEO friendly url slug from your article / post / page / news etc title.

If a article title is “Article title to url slug with cakephp” then your SEO friendly url slug supposed to be “article-title-to-url-slug-with-cakephp”

To create this kinds of url slug from a string you can use cakephp core utility class Inflector, The Inflector takes a string and manipulate it to handle some common words variations.

To make slug from string using Inflector you can use below written code in your controller:


For your multiple use you can create a common method on your application controller like


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: