PHPackages                             alistairshaw/name-exploder - 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. alistairshaw/name-exploder

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

alistairshaw/name-exploder
==========================

Simple class to provide title, first name, middle initial and last name from a full name field (or in reverse). Works well for western(ish) names, but has sensible defaults otherwise

0.1.3(8y ago)115.5k↑17.9%11MITPHPPHP &gt;=5.4

Since Apr 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/alistairshaw/name-exploder)[ Packagist](https://packagist.org/packages/alistairshaw/name-exploder)[ Docs](https://github.com/alistairshaw/name-exploder)[ RSS](/packages/alistairshaw-name-exploder/feed)WikiDiscussions master Synced 1mo ago

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

Install
-------

[](#install)

Via Composer

```
$ composer require alistairshaw/name-exploder:^0.1
```

Titles
------

[](#titles)

There is some data included for titles in English (default) and Spanish. If you need it for another language, please feel free to pull request or simply send me the list and I will add your language. Include any rules so we can improve the plugin.

It is possible to attach your own data (see below).

Usage
-----

[](#usage)

```
require 'vendor/autoload.php';

use AlistairShaw\NameExploder\NameExploder;

// You can get a Name object by passing in the full name
$nameExploder = new NameExploder();
$name = $nameExploder->explode('Mr Alistair Shaw');

// get the pieces back
echo $name->firstName();
echo $name->lastName();
echo $name->title();
echo $name->middleInitial();

// cast the Name object as string to just get full name back
echo $name;

// pass in the language for the titles (default is english)
$nameExploder = new NameExploder('es');
$name = $nameExploder->explode('Mr Alistair Shaw');

// make a name from pieces
$name = $nameExploder->implode('Alistair', 'Shaw', '', 'Mr');

// update the title on a name
$name = $nameExploder->updateTitle('Dr', $name);
```

Attaching your own data for titles
----------------------------------

[](#attaching-your-own-data-for-titles)

You can easily write a new repository (implement \\AlistairShaw\\NameExploder\\Title\\TitleRepository) and inject it into the main class Just ensure you return an array of Title objects, and it will work great!

```
require 'vendor/autoload.php';

use AlistairShaw\NameExploder\NameExploder;

// pass in a custom repository implementation
$nameExploder = new NameExploder('es', new CustomTitleRepository());
$name = $nameExploder->explode('Mr Alistair Shaw');
```

Notes
-----

[](#notes)

I realise that this is pretty basic at the moment, I plan to improve it over time, specifically adding new languages is high on the list of priorities. Would love to hear from people who speak non-latin languages to make this work for them.

Contributing
------------

[](#contributing)

Contributions are very welcome and will be fully credited, just please make sure to add tests.

Credits
-------

[](#credits)

- [Alistair Shaw](https://github.com/alistairshaw)
- [All Contributors](https://github.com/alistairshaw/name-the-color/contributors)

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% 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 ~224 days

Total

4

Last Release

3014d ago

PHP version history (2 changes)0.1PHP &gt;=5.6.0

0.1.1PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/73f9bfd4563c8c2fc004079fd5a3141ac7be60b247f64d05a36b1fffe975697a?d=identicon)[alistairshaw](/maintainers/alistairshaw)

---

Top Contributors

[![alistairshaw](https://avatars.githubusercontent.com/u/2110205?v=4)](https://github.com/alistairshaw "alistairshaw (14 commits)")[![selfsimilar](https://avatars.githubusercontent.com/u/784446?v=4)](https://github.com/selfsimilar "selfsimilar (1 commits)")

---

Tags

Initialsnamessurnamewestern namestitlesfirst namelast name

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alistairshaw-name-exploder/health.svg)

```
[![Health](https://phpackages.com/badges/alistairshaw-name-exploder/health.svg)](https://phpackages.com/packages/alistairshaw-name-exploder)
```

###  Alternatives

[lasserafn/php-initials

A package to generate initials in PHP

414.7M3](/packages/lasserafn-php-initials)[rackbeat/laravel-ui-avatars

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

43144.3k](/packages/rackbeat-laravel-ui-avatars)[watson/nameable

Format names of users into full, familiar and abbreviated forms

299.7k](/packages/watson-nameable)[dragon-code/laravel-route-names

Automatic generation of route names

259.2k1](/packages/dragon-code-laravel-route-names)[mihanentalpo/fio-analyzer

Analyze user input string, and split it into Russian first name, second name and last name

1422.9k](/packages/mihanentalpo-fio-analyzer)

PHPackages © 2026

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