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

ActiveLibrary

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

1.2.0(7y ago)534.0k↑70.8%7MITPHP

Since Apr 12Pushed 7y 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 1mo 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

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community12

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

2878d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a90b03a697d3734da2112cdd496a854a0b96055006c0d8121afc9f0e5f131c2f?d=identicon)[mcharytoniuk](/maintainers/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)
