nasirkhan/module-manager
Laravel module management for Laravel Starter: track module versions, handle migrations and updates, resolve dependencies, publish/enable/disable modules, scaffold/build modules, diff changes, and generate module tests via artisan commands.
Installation
composer require nasirkhan/module-manager
Verify Installation
php artisan module:status
This lists all available modules and their status (enabled/disabled).
First Use Case: Enable a Module
php artisan module:enable Post
This enables the Post module, making its routes, migrations, and services available.
php artisan module:status to see all modules and their versions.php artisan module:dependencies Post.php artisan module:track-migrations Post --force
php artisan module:detect-updates Post
php artisan migrate
Build a New Module (if needed):
php artisan module:build Blog
This scaffolds a new module in Modules/Blog/ with all standard directories.
Publish Module Assets (for customization):
php artisan module:publish Blog
This copies the module to Modules/ for local modifications.
Enable and Test:
php artisan module:enable Blog
php artisan migrate
php artisan module:enable Post
php artisan module:disable Category
php artisan module:remove Tag
php artisan module:dependencies Post
$service = app(\Nasirkhan\ModuleManager\Services\ModuleVersion::class);
if (!$service->dependenciesSatisfied('Post')) {
// Handle missing dependencies
}
php artisan module:track-migrations Post --force
php artisan module:detect-updates Post
php artisan module:check-migrations Post
module.json priority.Modules/Post/Providers/AppServiceProvider.php).priority in module.json loads first).php artisan vendor:publish --tag=post-routes
php artisan module:make-test Post UserModelTest --unit
$this->assertTrue($service->dependenciesSatisfied('Post'));
php artisan vendor:publish --tag=post-config
config/module-manager.php or module-specific config files.ModuleVersion service to load modules conditionally:
$modules = $service->getModulesByPriority();
foreach ($modules as $module) {
if ($service->isEnabled($module)) {
// Load module-specific logic
}
}
$tracker = app(\Nasirkhan\ModuleManager\Services\MigrationTracker::class);
$tracker->trackModuleMigrations('Post', '1.0.0');
$newMigrations = $tracker->getNewMigrationsSinceLastCheck('Post');
php artisan vendor:publish --tag=post-migrations --tag=post-views --tag=post-config --tag=post-lang
php artisan module:publish Post
Then modify Modules/Post/Console/Kernel.php.composer dump-autoload
php artisan config:clear
composer update:
php artisan module:track-migrations --force
php artisan module:detect-updates
php artisan vendor:publish --tag={module}-migrations
php artisan migrate:fresh
A requires B, B requires A) will fail silently. Use:
php artisan module:dependencies A
to debug.priority in module.json may load in an undefined order. Explicitly set priorities (e.g., 10 for core, 5 for UI).Modules/{module}/) are not synced back to vendor. To update:
composer update nasirkhan/module-manager
php artisan module:publish {module} --force
composer dump-autoload
php artisan cache:clear
php artisan config:clear
module.json for typos in name or alias.priority in module.json and check for conflicts.php artisan vendor:publish --tag={module}-routes
priority in module.json.register() and boot() methods in Modules/{module}/Providers/{Provider}.php.php artisan module:disable AllBut Post
--step to debug:
php artisan migrate --step --pretend
module:check-migrations for unpublished migrations.module.json Validationname and alias fields are case-sensitive. Ensure consistency:
"name": "Post", // Must match directory name
"alias": "post" // Used in URLs/routes
php artisan module:enable Post
php artisan module:enable All
composer dump-autoload
npm run dev
php artisan module:publish --tag=module-scaffold
vendor/nasirkhan/module-manager/stubs/module/ to change templates.ModuleEnabled, ModuleDisabled) by publishing and extending:
php artisan module:publish Post
Then add listeners in Modules/Post/Providers/EventServiceProvider.php.php artisan module:publish Post
Then create Modules/Post/Console/Commands/ with your logic.php artisan vendor:publish --tag=post-migrations
Then modify Modules/Post/database/migrations/.php artisan module:disable UnusedModule
How can I help you explore Laravel packages today?