Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Name Parser

Name Parser Laravel Package

theiconic/name-parser

Language-independent PHP name parser that splits full names into parts like salutation, first/middle name, initials, nicknames, last name (incl. prefixes like von/de) and suffixes (Jr/III/PhD). Supports comma formats, multi-language rules, and customizable normalization/whitespace.

View on GitHub
Deep Wiki
Context7

A universal, language-independent name parser PHP library

Frequently asked questions about Name Parser
Does theiconic/name-parser support PHP 8.2+ and Laravel 10+?
The package hasn’t been updated since 2019, so it may not fully support PHP 8.2+ features like named arguments or JIT. Test thoroughly in your environment, and consider forking the repo to backport fixes if needed. Laravel 10+ compatibility depends on how you integrate it (e.g., wrapping it in a service provider).
How do I integrate this into Laravel’s service container?
Register the parser as a singleton in a service provider using `app()->singleton(NameParser::class, function ($app) { return new NameParser(); })`. Then bind it to a facade or inject it directly into controllers/services. For config flexibility, add a config file (e.g., `config/name-parser.php`) to override default parsing rules.
Can this handle non-Latin scripts like Chinese, Arabic, or Cyrillic names?
The parser is language-agnostic and should work with non-Latin scripts, but accuracy depends on the input format. Test with examples like Иван Иванов (Cyrillic) or محمد علي (Arabic) to validate. For complex scripts, you may need to extend the parser’s rules or pre-process the input.
How do I validate parsed names in Laravel forms?
Extend Laravel’s validator with a custom rule. For example, add `Validator::extend('name', function ($attribute, $value, $parameters, $validator) { $parser = app(NameParser::class); $result = $parser->parse($value); return !empty($result['given_name']); })`. Then use it in form requests like `required|name`.
What’s the best way to handle parsing failures or ambiguous names?
Store the raw input alongside parsed data, and flag ambiguous cases for review. Use Laravel’s events (e.g., `NameParsed`) to log parsing attempts. For critical systems, implement a fallback to store raw names and manually review edge cases like J.R.R. Tolkien or compound surnames.
Is this package suitable for real-time parsing (e.g., chatbots or APIs)?
The package is lightweight but wasn’t designed for real-time systems. Benchmark it against alternatives like Google’s Name Parser if low latency is critical. For APIs, consider caching parsed results or using a queue (e.g., Laravel Horizon) to offload parsing.
How do I map parsed names to a Laravel Eloquent model?
Normalize the parsed output (e.g., `given_name`, `family_name`) into your database schema. For example, store `given_name` in `users.first_name` and `family_name` in `users.last_name`. Use Laravel’s mutators/accessors to transform between raw and parsed formats.
Are there alternatives to this package for Laravel?
Alternatives include Laravel Nameable (for nameable models) or custom solutions using regex/rule-based parsing. Google’s Name Parser is another option but requires JavaScript. Evaluate based on your needs: this package excels in simplicity, while alternatives may offer better accuracy or Laravel-specific features.
How do I test this package in a Laravel application?
Use Laravel’s Testing facade to mock parser outputs. For example, test a user creation flow by asserting parsed names: `$this->assertEquals('John', $user->given_name)`. Test edge cases like non-Latin scripts, initials (e.g., J.R.R. Tolkien), and empty inputs to validate robustness.
What’s the maintenance status, and should I fork it?
The package is unmaintained since 2019, so consider forking to backport fixes for PHP 8.2+ or Laravel 10+. Check for open issues or contribute to a maintained alternative like Google’s Name Parser if accuracy is a priority. The MIT license allows forking without legal concerns.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle