This package is abandoned and no longer maintained. No replacement package was suggested.

Presenting names of people in full, familiar, abbreviated, and initialized forms (but without titulation etc)

v1.1.0 2020-04-16 08:57 UTC

This package is auto-updated.

Last update: 2022-02-04 15:37:21 UTC


Latest Version on Packagist Build Status Code Coverage Quality Score StyleCI Total Downloads

Presenting names for English-language applications where a basic model of first and last name(s) combined is sufficient. This approach is not meant to cover all possible naming cases, deal with other languages, or even titulations. Just the basics.

Sponsored by The Webstronauts


You can install the package via Composer.

composer require webstronauts/person-name



$name = new PersonName::make('David Heinemeier Hansson')

echo $name->full        // "David Heinemeier Hansson"
echo $name->first       // "David"
echo $name->last        // "Heinemeier Hansson"
echo $name->initials    // "DHH"
echo $name->familiar    // "David H."
echo $name->abbreviated // "D. Heinemeier Hansson"
echo $name->sorted      // "Heinemeier Hansson, David"
echo $name->mentionable // "davidh"
echo $name->possessive  // "David Heinemeier Hansson's"


This is an example model which exposes a name virtual attribute composed from the first_name and last_name attributes:


use Webstronauts\PersonName\PersonName;

class User extends Model
     * The attributes that are mass assignable.
     * @var array
    protected $fillable = [
        'name', 'first_name', 'last_name',

     * Return a PersonName instance composed from the `first_name` and `last_name` attributes.
     * @return PersonName
    public function getNameAttribute()
        return new PersonName($this->first_name, $this->last_name);

     * Sets the `first_name` and `last_name` attributes from a full name.
     * @param  string $name
     * @return void
    public function setNameAttribute($name)
        $fullName = PersonName::make($name);
        [$this->first_name, $this->last_name] = $fullName ? [$fullName->first, $fullName->last] : [null, null];


composer test


Detailed release notes for a given version can be found on our releases page.


This package is based on the name_of_person gem and we would like to mimic their functionality as close as possible. As the gem is in a frozen state, we also do not accept any PRs regarding new functionality. If you encounter a bug though, you're welcome to open an issue.


As it's just a simple port of Ruby to PHP code. All credits should go to the Basecamp team and their name_of_person gem.


The MIT License (MIT). Please see License File for more information.