misakstvanu / laravel-subdirectory-migrations
Automatically include all subdirectories in Laravel migration discovery
Package info
github.com/misakstvanu/laravel-subdirectory-migrations
pkg:composer/misakstvanu/laravel-subdirectory-migrations
Requires
- php: ^8.0
- illuminate/database: >=9.0
- illuminate/support: >=9.0
Requires (Dev)
- orchestra/testbench: >=7.0
- phpunit/phpunit: >=9.0
This package is auto-updated.
Last update: 2026-07-23 08:36:50 UTC
README
A super simple Laravel package that changes the migration discovery logic to automatically include all subdirectories under every registered migration path.
Installation
composer require misakstvanu/laravel-subdirectory-migrations
The package auto-discovers itself via Laravel's package discovery, so no manual provider registration is needed.
Usage
Organise your migrations into subdirectories however you like — the package will find them all automatically:
database/
└── migrations/
├── 2024_01_01_000000_create_users_table.php
├── orders/
│ ├── 2024_02_01_000000_create_orders_table.php
│ └── 2024_02_02_000000_create_order_items_table.php
└── payments/
└── 2024_03_01_000000_create_payments_table.php
Run migrations as normal:
php artisan migrate
All migration commands (migrate, migrate:rollback, migrate:status, migrate:fresh, etc.) will automatically pick up migrations in subdirectories.
How it works
During the boot phase, SubdirectoryMigrationsServiceProvider recursively walks database/migrations with RecursiveDirectoryIterator and calls loadMigrationsFrom() for every subdirectory found. Laravel's built-in migration commands then discover all those paths automatically. No configuration required.
License
MIT