PHPackages                             newridetech/php-classnames - 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. newridetech/php-classnames

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

newridetech/php-classnames
==========================

1.2.0(8y ago)535.9k↑28.8%7MITPHP

Since Apr 12Pushed 8y ago3 watchersCompare

[ Source](https://github.com/newridetech/php-classnames)[ Packagist](https://packagist.org/packages/newridetech/php-classnames)[ RSS](/packages/newridetech-php-classnames/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (6)Used By (7)

classnames
==========

[](#classnames)

This package is a PHP port of .

The only difference is that `Classnames` deduplicate classes by default. It means that `Classnames::make('foo', 'foo', 'bar)` returns `'foo bar'`instead of `foo foo bar` by default. It's because redraws in PHP do not happen that often as they do in JavaScript (original implementation) so it's not an issue and the output code is cleaner and smaller (which is more an issue in the backend).

If you want to use `Classnames` without deduplication you can call `Classnames::flatten`.

Generate CSS class names
------------------------

[](#generate-css-class-names)

```
use Newride\Classnames\Classnames;

Classnames::make('foo', 'bar'); // => 'foo bar'
Classnames::make('foo', [ 'bar' => true ]); // => 'foo bar'
Classnames::make([ 'foo-bar' => true ]); // => 'foo-bar'
Classnames::make([ 'foo-bar' => false ]); // => ''
Classnames::make([ 'foo' => true ], [ 'bar' => true ]); // => 'foo bar'
Classnames::make([ 'foo' => true, 'bar' => true ]); // => 'foo bar'
Classnames::make(1, 2, 3); // => '1 2 3'

Classnames::make('foo', 'foo', 'bar'); // => 'foo bar'
Classnames::flatten('foo', 'foo', 'bar'); // => 'foo foo bar'
```

Invalid class names
-------------------

[](#invalid-class-names)

When type non convertible to string is used as an argument then exception is thrown.

```
Classnames::flatten(new stdClass()); // => throws \Newride\Classnames\NotConvertibleTypeException
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Total

5

Last Release

2969d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1286785?v=4)[Mateusz Charytoniuk](/maintainers/mcharytoniuk)[@mcharytoniuk](https://github.com/mcharytoniuk)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/newridetech-php-classnames/health.svg)

```
[![Health](https://phpackages.com/badges/newridetech-php-classnames/health.svg)](https://phpackages.com/packages/newridetech-php-classnames)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
