PHPackages                             lasserafn/php-initials - 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. lasserafn/php-initials

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

lasserafn/php-initials
======================

A package to generate initials in PHP

3.1(5y ago)414.7M—3.7%5[2 issues](https://github.com/LasseRafn/php-initials/issues)3MITPHPPHP ^5.6|^7.0|^7.1|^8.0CI failing

Since Feb 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/LasseRafn/php-initials)[ Packagist](https://packagist.org/packages/lasserafn/php-initials)[ RSS](/packages/lasserafn-php-initials/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (11)Used By (3)

Generate initials from names
============================

[](#generate-initials-from-names)

This is the core of [LasseRafn/php-initial-avatar-generator](http://github.com/LasseRafn/php-initial-avatar-generator), or well.. the initials generation part of it.

It's framework agnostic, which is different from basically everything else I do, you're welcome.

Supports UTF8 (yes, also emojis.)

 [![Code Coverage](https://camo.githubusercontent.com/4c7704cb87848bb25e340a592fced3c4e0e64252bed3f7ed294f372971adb2a0/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6f74746572776973652e6170702f62616467652f6769746875622f6c617373657261666e2f7068702d696e697469616c732f37333537636262322d303437342d343239312d616239392d313630373332323864636366)](https://otterwise.app/github/lasserafn/php-initials)[![StyleCI Status](https://camo.githubusercontent.com/f62aa8b0c1899ab7ecf63aeb7daac1e22d0a3dd0d142dc3ecf646ad924aa0460/68747470733a2f2f7374796c6563692e696f2f7265706f732f37383937333731302f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/78973710)[![Total Downloads](https://camo.githubusercontent.com/a7d0845f5d8bf53bac79e1d70d78a88c7ad6cd42f95c97d616ab7681a028cf5c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4c617373655261666e2f7068702d696e697469616c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/LasseRafn/php-initials)[![Latest Stable Version](https://camo.githubusercontent.com/f9b5751737c3937c023ec41963fbef5249d4902c8156ae387156848bd2fb9f17/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f4c617373655261666e2f7068702d696e697469616c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/LasseRafn/php-initials)[![License](https://camo.githubusercontent.com/891519dc31c48b189ad4290d8fe16393fccb97cf55206d94e7cd6ccff350d940/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f4c617373655261666e2f7068702d696e697469616c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/LasseRafn/php-initials)

Installation
------------

[](#installation)

You just require using composer and you're good to go!

```
composer require lasserafn/php-initials
```

Usage
-----

[](#usage)

As with installation, usage is quite simple. Generating a image is done by running:

```
use LasseRafn\Initials\Initials;

echo (new Initials('Lasse Rafn'));                                   // Output: LR
echo (new Initials)->name('Justine Bieber')->generate();             // Output: JB
echo (new Initials('John Christian Doe'))->generate();               // Output: JD
echo (new Initials)->generate('Leonardo');                           // Output: LE
echo (new Initials)->length(1)->generate('Camilla');                 // Output: C
echo (new Initials)->name('Jens Ølsted')->getUrlfriendlyInitials();  // Output: JO
```

All you'll have to do is either pass in the name in the constructor like so:

```
echo new Initials('The Name Here'); // TH
```

or use the `name($name)` method, to specify the name.

Supported methods
-----------------

[](#supported-methods)

### name($name = 'John Doe')

[](#namename--john-doe)

```
$initials->name('Albert Magnum')->generate();
```

### length($length = 2)

[](#lengthlength--2)

```
$initials->name('Albert Magnum')->length(3)->generate();
```

### generate()

[](#generate)

This method will output the initials. It's completely optional, you could also just echo out the class as it has a `__toString()` method.

```
$initials->name('Albert Magnum')->generate();
```

### getUrlfriendlyInitials()

[](#geturlfriendlyinitials)

Will output url-friendly initials (stripping characters like ÆØÅ)

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

[](#requirements)

- PHP 5.6, 7.0 or 7.1

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity55

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~176 days

Recently: every ~322 days

Total

9

Last Release

1972d ago

Major Versions

v1.9 → v2.02017-02-14

v2.2 → 3.02020-02-17

PHP version history (3 changes)v1.9PHP ^7.0|^7.1

v2.16PHP ^5.6|^7.0|^7.1

3.1PHP ^5.6|^7.0|^7.1|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fd953630eb9784e977637a0fe53be91b9dd4b0262a5b5b1fa9277e0c2806b65c?d=identicon)[lasserafn](/maintainers/lasserafn)

---

Top Contributors

[![LasseRafn](https://avatars.githubusercontent.com/u/2689341?v=4)](https://github.com/LasseRafn "LasseRafn (36 commits)")

---

Tags

initialsnamephpphp56php7phpInitials

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lasserafn-php-initials/health.svg)

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

###  Alternatives

[rackbeat/laravel-ui-avatars

Official Laravel wrapper around ui-avatars.com and LasseRafn/php-initial-avatar-generator

43144.3k](/packages/rackbeat-laravel-ui-avatars)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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