Installation Add the package via Composer in your Laravel-based CVEPDB CMS project:
composer require cvepdb-cms/module-installer
Publish the package’s configuration (if available):
php artisan vendor:publish --provider="CvepdbCms\ModuleInstaller\ModuleInstallerServiceProvider"
First Use Case Install a module via CLI:
php artisan module:install <module-name>
Verify installation by checking the modules table (if using a database-backed system) or the filesystem for module assets.
Where to Look First
CvepdbCms\ModuleInstaller\ModuleInstallerServiceProvider (registers commands, events, and bindings).CvepdbCms\ModuleInstaller\Console\InstallModuleCommand (core logic for installation).config/module-installer.php (if published; defines paths, defaults, or module metadata).Module Installation
php artisan module:install with optional flags (e.g., --force, --skip-migrations).$installer = app(\CvepdbCms\ModuleInstaller\ModuleInstaller::class);
$installer->install('module-name');
ModuleInstalled events to trigger post-install hooks (e.g., cache warming, notifications).Module Uninstallation
php artisan module:uninstall <module-name>
--drop-tables flag is used).Dependency Management
composer require for PHP dependencies or module:install for CMS modules).composer.json or a module.json manifest for dependencies before installation.Post-Install Hooks
npm run dev or php artisan asset:publish for module-specific assets.chmod -R 755 storage/module-cache).ModuleName/ModuleNameServiceProvider.php, config/module.php). Example:
/modules/
├── auth/
│ ├── AuthServiceProvider.php
│ ├── migrations/
│ └── config/auth.php
ModuleInstaller::registerServiceProviders() to dynamically load module providers after installation.config/ directory during installation:
$this->mergeConfigFrom(
$modulePath . '/config/module.php',
'module.module-name'
);
resources/lang/ during installation.Namespace Collisions
UserController) will cause autoloader conflicts.AuthUserController).Database Conflicts
--force) may fail.--drop-tables cautiously or implement blue-green migration strategies.Circular Dependencies
module.json or use a dependency resolver.Filesystem Permissions
storage/ or bootstrap/cache/ may fail if permissions are too restrictive.php artisan module:install with a user owning the directories (e.g., sudo -u www-data).Composer Autoloading
composer dump-autoload.composer dump-autoload manually or hook it into the installer.--verbose flag for detailed logs:
php artisan module:install <name> --verbose
php artisan module:install <name> --dry-run
Event::ignore(
\CvepdbCms\ModuleInstaller\Events\ModuleInstalled::class
);
class CustomInstaller extends \CvepdbCms\ModuleInstaller\ModuleInstaller {
protected function postInstallHooks($module) {
// Add custom logic (e.g., API key setup)
}
}
Event::listen(\CvepdbCms\ModuleInstaller\Events\ModuleInstalling::class, function ($event) {
// Pre-install logic
});
module.json:
{
"name": "auth",
"description": "Authentication module",
"dependencies": ["database"],
"hooks": {
"post-install": "php artisan auth:publish"
}
}
$installer = Mockery::mock(\CvepdbCms\ModuleInstaller\ModuleInstaller::class);
$installer->shouldReceive('install')->once();
base_path('modules') by default. Override in config:
'paths' => [
'modules' => base_path('custom-modules'),
],
app() checks for config('app.env') === 'local'). Handle this in the installer’s supports() method.InstallModulesJob::dispatch(['module1', 'module2']);
Cache::remember('module-metadata', now()->addHours(1), function () {
return ModuleInstaller::getAllModules();
});
How can I help you explore Laravel packages today?