Skip to content

feat(install): migrate app folders into the layers - #50

Merged
danielebarbaro merged 3 commits into
mainfrom
feat/install-migrate-app
Nov 16, 2026
Merged

danielebarbaro merged 3 commits into
mainfrom
feat/install-migrate-app

Conversation

@danielebarbaro

@danielebarbaro danielebarbaro commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #49, merge that first.

Running clean-arch:install on an existing app creates the new layer folders but moves nothing. With a starter kit you end up with two base controllers, duplicated Middleware and Requests folders, and app/Actions still outside the layers.

This adds clean-arch:install --migrate-app, which moves the existing code into the layers:

From app/ To
Http/Controllers, Http/Middleware, Http/Requests, Http/Resources Infrastructure/Http/...
Console/Commands Infrastructure/Console/Commands
Mail, Notifications, Observers, Exports Infrastructure/...
Actions, Services, Jobs, Listeners, Concerns Application/...
Models/User.php (only if it's the only model) Domain/Users/Models/User.php

What it does along the way:

  • Rewrites namespaces in app/, bootstrap/, config/, database/, routes/ and tests/.
  • Replaces Laravel's empty base Controller with the one install writes.
  • Registers moved commands and listeners in bootstrap/app.php, or prints the lines to add if it can't do it safely.
  • Updates Wayfinder imports in resources/js and resources/ts.
  • Checks every destination before moving anything. On a conflict it stops and changes nothing, unless you pass --force.
  • Lists every PHP file still outside the layers at the end. Folders it doesn't know about (Providers, Policies, other models, Livewire) are left alone.

It also fixes a bug in --user-in-domain: references with a leading backslash, like \App\Models\User::class, were not rewritten. It now scans bootstrap/ too.

Tested by migrating a copy of the Laravel React starter kit and running phparkitect check on it with the rule from #49 turned on.

Limits: paths inside strings like app_path('Http/...') aren't rewritten, non PHP files aren't touched (except Wayfinder imports), and use statements aren't re sorted, so run Pint afterwards. Not tried on the Vue and Livewire kits yet.

Nothing changes without the new flag. Minor release.

@danielebarbaro
danielebarbaro force-pushed the feat/install-migrate-app branch from 0117991 to 0ed1d19 Compare November 16, 2026 13:09
@danielebarbaro
danielebarbaro force-pushed the feat/no-classes-outside-layers branch from 768e2cf to d0f8999 Compare November 16, 2026 13:09
Base automatically changed from feat/no-classes-outside-layers to main November 16, 2026 13:17
@danielebarbaro
danielebarbaro merged commit 0ed1d19 into main Nov 16, 2026
8 of 16 checks passed
@danielebarbaro
danielebarbaro deleted the feat/install-migrate-app branch November 16, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant