Skip to content
This documentation is in construction.

Write your own

A module is a standard Laravel Service Provider that additionally implements the Epsicube\Support\Contracts\IsModule interface.

This contract exposes the metadata required by Epsicube to register, identify, and manage your module.


  1. Generate a new module using Laravel’s CLI:

    Terminal window
    php artisan make:module MyCustomModule
  2. Open the generated file app/Modules/MyCustomModule.php

    use Illuminate\Support\ServiceProvider;
    use Epsicube\Support\Contracts\IsModule;
    use Epsicube\Support\Modules\Identity;
    use Epsicube\Support\Modules\Module;
    class MyCustomModule extends ServiceProvider implements IsModule
    {
    public function module(): Module
    {
    return Module::make('custom::your-module-identifier', '0.0.1')
    ->providers(static::class)
    ->identity(fn (Identity $identity) => $identity
    ->name('MyCustomModule')
    ->description('')
    ->author('Internal dev')
    );
    }
    //...
    }
  3. By default, the module:make command registers your module in bootstrap/modules.php.

    You may also manually create or update the bootstrap/modules.php file:

    <?php
    return [
    //...
    App\Modules\MyCustomModule::class,
    ];
  4. By default, the module:make command enables your module (unless you use the --disabled option).

    You may also enable it manually using:

    Terminal window
    php artisan modules:enable {identifier}

When your module needs to disable one or more Laravel package providers, declare them in module(): Module with preventProviders().

use Epsicube\Support\Contracts\IsModule;
use Epsicube\Support\Modules\Module;
use Illuminate\Support\ServiceProvider;
use Vendor\Package\PackageServiceProvider;
class BillingModule extends ServiceProvider implements IsModule
{
public function module(): Module
{
return Module::make('app::billing', '1.0.0')
->providers(static::class)
->preventProviders(PackageServiceProvider::class);
}
}

During application bootstrap, Epsicube updates Laravel’s package manifest before providers are registered. Any provider declared through preventProviders() is excluded from Laravel’s discovered provider list for that boot cycle.

Use this when your module replaces a package integration, needs to avoid duplicate bindings, or must prevent a conflicting package provider from loading.

  • Package Development — Learn how to create reusable packages with configuration, migrations, assets, and service providers.