dragon-code/laravel-app
Lightweight Laravel package that wraps application metadata in convenient helpers, letting you retrieve the app name, version, environment, and debug state anywhere in your code. Easy to install and configurable.
dragon-code/laravel-app is a single-command shim. Laravel removed php artisan app:name in 9.x; this package re-registers it via auto-discovery so you can still rename the root PHP namespace (App\ → Acme\) on a fresh skeleton. That is the entire feature surface — no config file, no facade, no runtime behaviour.
Install (dev-only, one-shot):
composer require --dev dragon-code/laravel-app
php artisan list | grep app:name # confirm the command registered
First use case — rename before you write any code:
laravel new billing-service && cd billing-service
composer require --dev dragon-code/laravel-app
git init && git add -A && git commit -m "skeleton" # snapshot first
php artisan app:name Acme
git diff --stat
composer dump-autoload
php artisan config:clear && php artisan test
Where to look first: vendor/dragon-code/laravel-app/src/ — the command class is short and readable. Diff it mentally against Laravel 8's original AppNameCommand to see exactly which directories and files it rewrites. Read that list before running it, because what it silently skips is the whole risk here.
Because the repo is archived (last release 2022-02-14) and the package is essentially frozen at the Laravel 8/9 era, treat the install step as the first real decision: check composer show -a dragon-code/laravel-app for the illuminate/console constraint and whether it resolves against your Laravel version. On Laravel 10+ expect it to fail or to produce a partial rewrite — see Gotchas.
One-shot dev dependency (recommended). Install, rename, then remove so the archived package never sits in a future composer update path:
php artisan app:name Acme
composer dump-autoload -o
composer remove --dev dragon-code/laravel-app
Scaffold-script pattern. Wrap it in an idempotent bootstrap script used by laravel new + a post-create step, or by your own project generator:
#!/usr/bin/env bash
set -euo pipefail
NS="${1:?namespace required}"
# only if the skeleton is untouched
grep -q '^namespace App;' app/Models/User.php || { echo "already renamed"; exit 0; }
composer require --dev dragon-code/laravel-app --no-interaction
php artisan app:name "$NS"
composer dump-autoload -o
php artisan config:clear
composer remove --dev dragon-code/laravel-app --no-interaction
# app:name only touches the namespace — do the rest explicitly:
composer config name "acme/$(basename "$PWD")"
sed -i.bak "s/^APP_NAME=.*/APP_NAME=${NS}/" .env && rm -f .env.bak
Template-repo / boilerplate pattern. Keep the rename as a documented first step in your internal starter repo's README, pinned to a Laravel version the package actually supports. Do not carry a renamed template forward and re-run the command later — it is a bootstrap tool, not a refactoring tool.
CI guard. Assert the namespace matches the expected value so a forgotten rename fails fast:
test "$(grep -m1 '^namespace' app/Models/User.php | sed 's/namespace \(.*\);/\1/')" = "$EXPECTED_NS"
Fork-and-patch pattern for modern Laravel. Since the package is archived, the realistic "extension point" is a fork: copy src/ into your own Acme\Tooling\AppNameCommand, add the directories the 2022 version doesn't know about (tests/, database/factories/ use App\Models\... imports, bootstrap/providers.php), register it in a dev-only service provider. This is more work than a grep loop but gives you a repeatable, version-controlled tool.
Manual fallback when the package won't install:
NS=Acme
grep -rl --include='*.php' -E '\bApp\\' app database tests routes config bootstrap \
| xargs sed -i "s/\\\\bApp\\\\\\\\/\\\\b${NS}\\\\\\\\/g; s/^namespace App;/namespace ${NS};/"
sed -i "s/\"App\\\\\\\\\": \"app\/\"/\"${NS}\\\\\\\\": \"app\/\"/" composer.json
composer dump-autoload
database/seeds-era layouts, not Laravel 11's bootstrap/providers.php or the Database\Factories / Database\Seeders namespaces. On L10/L11 you will get a partially renamed app — worse than no rename, because it compiles until something resolves a class at runtime.tests/. Test classes keep use App\Models\User; and break immediately. Same for anything outside app/, config/, composer.json — custom routes/*.php imports, phpunit.xml bootstrap helpers, IDE-helper _ide_helper_models.php, PHPStan baselines.'App\\Jobs\\Foo' in a config array, a morph map, a Relation::morphMap(), or a $dispatchesJobs list will not be rewritten. Grep for 'App\\ and "App\\ in quotes after running.failed_jobs payloads, cache entries holding App\... class names, and Laravel's packages.php/services.php caches will reference classes that no longer exist. Run php artisan optimize:clear and drain failed_jobs before the rename, or accept re-queuing.--revert. The command rewrites files in place with no dry run and no backup. git commit before, git diff after. This is the single most important habit.Acme, BillingService). app:name acme produces namespace acme; and PSR-4 lookups become case-sensitive in ways that bite only on Linux CI. Avoid PHP reserved words and anything colliding with a Composer vendor prefix (e.g. Carbon).composer dump-autoload -o --strict-psr, php artisan config:clear, php artisan optimize:clear, then php artisan test. If --strict-psr complains, the rename was partial.APP_NAME. app:name changes the PHP namespace and composer.json autoload mapping only. Your .env APP_NAME and composer.json name field are untouched — set them yourself, they are the fields users actually see.App\ will be rewritten in place, including files you hand-edited. It's a bootstrap tool; after the first feature commit, do a manual rename or a fork-based tool.vendor/_laravel_idea, PHPStan result cache, PhpStorm indexes) will show phantom classes. Invalidate caches and delete *.resultCache if analysis goes strange.grep -rn '^namespace App' app/ database/ tests/ should return nothing; grep -rn 'App\\\\' app/ config/ routes/ | head surfaces leftover string references; composer dump-autoload -o --strict-psr is the fastest structural check.require-dev for a production app.How can I help you explore Laravel packages today?