fzaninotto/company-name-generator
Generate random, believable company names in PHP with fzaninotto/company-name-generator. Ideal for database seeders, test fixtures, and demo apps, it offers a simple API and Composer installation with no heavy dependencies.
This is a single-class, dependency-free library — not a Laravel package. There is no service provider, no facade, no config, and no auto-discovery. Installation is a one-liner:
composer require fzaninotto/company-name-generator
Because it is archived and has zero dependents, treat it as "vendored convenience code" rather than infrastructure — pin it in composer.json and don't expect fixes.
The first thing to do is open vendor/fzaninotto/company-name-generator/src/Generator.php. The entire library is one short class containing two word lists (prefixes and suffixes) and one method that picks a random pair. Confirm the exact namespace and method name there before writing anything else — this is a 2016-era package and the public surface is one call:
use Fzaninotto\CompanyNameGenerator\Generator;
$generator = new Generator();
echo $generator->generateName(); // e.g. "Blue Labs", "Big Soft"
The natural first use case in Laravel is demo and test data: naming fake tenants, organisations, or accounts in seeders and factories where "Acme Corp" repeated 200 times makes the UI untestable. Reach for it in a seeder before you reach for anything else.
Wrap it, don't scatter it. Bind a tiny interface in a service provider so tests and future replacements don't depend on the concrete class:
// app/Support/CompanyNamer.php
interface CompanyNamer { public function next(): string; }
// app/Support/GeneratedCompanyNamer.php
final class GeneratedCompanyNamer implements CompanyNamer
{
public function next(): string
{
return (new \Fzaninotto\CompanyNameGenerator\Generator())->generateName();
}
}
// app/Providers/AppServiceProvider.php
$this->app->singleton(CompanyNamer::class, GeneratedCompanyNamer::class);
Factory states. The most common day-to-day pattern:
// database/factories/CompanyFactory.php
public function definition(): array
{
$name = app(CompanyNamer::class)->next();
return [
'name' => $name,
'slug' => Str::slug($name),
'email' => 'hello@'.Str::slug($name).'.test',
];
}
Seeders need uniqueness. The word lists are small, so collisions are frequent. Wrap in a retry or collect into a set:
$seen = [];
while (count($seen) < 50) {
$seen[app(CompanyNamer::class)->next()] = true;
}
Testing. Because it's random, inject a deterministic fake in tests:
$this->app->instance(CompanyNamer::class, new class implements CompanyNamer {
public function next(): string { return 'Fixed Company'; }
});
If you want reproducible output without a fake, seed the RNG (mt_srand(42)) in setUp() — verify in the source whether it uses mt_rand/array_rand so your seed actually takes effect.
Preview command. A small artisan command that prints 20 names is the fastest way to evaluate whether the vocabulary suits your domain and to sanity-check dedupe rates:
public function handle(CompanyNamer $namer): void
{
for ($i = 0; $i < 20; $i++) {
$this->line($namer->next());
}
}
Composition with Faker. For richer fixtures, use this for the display name and Faker for domain, address, and phone so you don't get Blue Labs at company1.test:
'domain' => Str::slug($name).'.'.fake()->tld(),
require-dev-style use, but do not put it on a real customer-facing code path. If it bothers you, "replace" it or fork the ~50 lines into app/Support.unique index on companies.name will throw. Handle with a retry loop or dedupe before insert rather than catching QueryException.rand() vs mt_rand(). Prefer the injected-fake pattern above for anything you actually assert on.Class not found after install, check composer dump-autoload -o and confirm the namespace in the file header — the namespace in the source doesn't always match what the package name implies.Arr::random() yourself. That removes the dependency, gives you control over the vocabulary, and eliminates the abandoned-package warning entirely.How can I help you explore Laravel packages today?