make:module
Scaffolds a self-contained module folder under app/Modules/.
Signature
bash
php nikogin make:module {ModuleName}Example
bash
php nikogin make:module CrmGenerated output
app/Modules/Crm/
├── Controllers/.gitkeep
├── Repository/.gitkeep
├── Listeners/.gitkeep
├── Providers/
│ └── CrmServiceProvider.php
└── routes/
└── routes.phpphp
// app/Modules/Crm/Providers/CrmServiceProvider.php
namespace Nikogin\Modules\Crm\Providers;
use Nikogin\Framework\Abstracts\ServiceProvider;
use Nikogin\Framework\Attributes\AsModule;
#[AsModule(name: 'crm')]
class CrmServiceProvider extends ServiceProvider
{
public function priority(): int
{
return 10;
}
protected array $services = [];
public function boot(): void
{
}
}php
// app/Modules/Crm/routes/routes.php
<?php
// Routes for the crm module.Naming
- Folder name (
app/Modules/{ModuleName}) uses the class name exactly as typed —CrmstaysCrm. - The
#[AsModule(name: ...)]value is the snake_case of the class name (same conversionmake:listeneruses for its hook name) —Crm→crm,BigFeature→big_feature. This is the key you use inconfig/modules.phpto enable/disable the module, so it doesn't have to match the folder name if you rename one later.
Next steps
- Add services to
$services— see Service Providers for the full syntax. - Add routes to
routes/routes.php— see Routing. - Add controllers/repositories/listeners into the module's own subfolders; wire them through
$serviceslike you would inapp/Providers/.
Error handling
bash
# Missing class name
Error: Class name is required. Usage: make:module {ModuleName}
# Module already exists — never overwritten
Error: Module already exists: app/Modules/Crm