PHPackages                             davidyell/css-safe-slug - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. davidyell/css-safe-slug

AbandonedArchivedCakephp-plugin[Utility &amp; Helpers](/categories/utility)

davidyell/css-safe-slug
=======================

Converts a slug into a safe to use css class

0.1.3(11y ago)0250PHP

Since May 9Pushed 8y ago1 watchersCompare

[ Source](https://github.com/davidyell/CakePHP-CssSafeSlug)[ Packagist](https://packagist.org/packages/davidyell/css-safe-slug)[ RSS](/packages/davidyell-css-safe-slug/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (5)Used By (0)

CakePHP-CssSafeSlug
===================

[](#cakephp-csssafeslug)

In most web apps you will be using a slug to uniquely identify an article or item from the database. This gives you a clean way to access the item in the url. However, in CSS classes are not allowed to start with a number. This is a simple helper which will convert any slug which begins with a number into a safe string which can be used for a css class.

Looking for CakePHP 3? Try this,

Requirements
------------

[](#requirements)

- PHP 5.3.0+
- Intl

Example
-------

[](#example)

```
Article
  Title: "99 Ways to solve a puzzle"
  Slug: "99-ways-to-solve-a-puzzle"
  Unsafe css: "99-ways-to-solve-a-puzzle"
  Safe: "ninety-nine-ways-to-solve-a-puzzle"
```

Usage
-----

[](#usage)

You will need to put the code in your `app/Plugin/CssSafeSlug`, and load the plugin in your `app/bootstrap.php` using `CakePlugin::load('CssSafeSlug');`.

It is also available on Composer. `composer require davidyell/css-safe-slug`

You can call the helper in your view.

```
