nasirkhan/module-manager
Laravel module manager for Laravel Starter with version tracking, migration baselines/updates, dependency checks, publish/diff workflows, and enable/disable lifecycle commands. Includes scaffolding, removal, and test generation via Artisan.
composer require nasirkhan/module-manager
php artisan vendor:publish --tag=module-manager-config
php artisan module:status
Post):
php artisan module:enable Post
php artisan module:dependencies Post
php artisan module:track-migrations Post
php artisan migrate
Modules/ directory (auto-generated after publishing).module.json (module metadata and dependencies).config/module-manager.php (published config).php artisan module:build MyModule
Modules/MyModule/ with standard Laravel structure.module.json:
{
"requires": ["Category", "Tag"]
}
php artisan module:publish MyModule
php artisan module:track-migrations MyModule --force
Modules/{Module}/Providers/.Route::module('post', function () { ... }) or publish routes via module:publish.Http/Middleware/ and bind to routes.php artisan module:make-test MyModule UserTest --unit
php artisan module:dependencies MyModule
$service = app(\Nasirkhan\ModuleManager\Services\ModuleVersion::class);
if (!$service->dependenciesSatisfied('MyModule')) {
// Handle missing dependencies
}
composer update:
php artisan module:detect-updates MyModule
php artisan vendor:publish --tag=my-module-migrations
php artisan migrate
priority in module.json to control load order (higher = loads first).$modules = app(\Nasirkhan\ModuleManager\Services\ModuleVersion::class)
->getModulesByPriority();
Namespace Conflicts:
composer dump-autoload
php artisan config:clear
Modules/{Module}/ namespaces match the published structure.Missing Dependencies:
module:dependencies to debug. Example output:
[ERROR] Module "Post" requires "Category" (v1.0.0), but found v0.9.0.
module.json.Migrations Not Detected:
php artisan module:track-migrations MyModule --force
php artisan cache:clear
Routes Not Loading:
module:status).Modules/{Module}/routes/.Circular Dependencies:
module.json contains circular requires (e.g., A requires B, B requires A).php artisan module:status MyModule --verbose
php artisan module:diff MyModule --detailed
config/module-manager.php:
'debug' => env('MODULE_MANAGER_DEBUG', false),
Custom Module Build Templates:
resources/stubs/module-manager/ (if using Laravel Starter).module:build command by publishing its templates:
php artisan vendor:publish --tag=module-manager-stubs
Hooks for Lifecycle Events:
ModuleEnabled, ModuleDisabled) via Laravel’s event system.use Nasirkhan\ModuleManager\Events\ModuleEnabled;
ModuleEnabled::subscribe(function ($event) {
Log::info("Module {$event->module} enabled!");
});
Custom Migration Tracking:
MigrationTracker to add pre/post-migration hooks:
$tracker = app(\Nasirkhan\ModuleManager\Services\MigrationTracker::class);
$tracker->extend(function ($module) {
// Custom logic before tracking
});
php artisan module:disable UnusedModule
--force sparingly for module:track-migrations to avoid accidental overwrites.priority, the alphabetically first one loads first.php artisan module:enable MyModule
module:diff to compare versions before updating:
php artisan module:diff MyModule --detailed > backup/diff.txt
php artisan module:make-test MyModule FeatureTest
php artisan test --filter=MyModule
module.json Keywords:
keywords for internal tagging (e.g., "keywords": ["admin", "ui"]) to filter modules programmatically.How can I help you explore Laravel packages today?