Skip to content
This documentation is in construction.

Declare Supports

The Support system allows your module to interact and adapt to its environment dynamically.

By defining supports, your module can execute specific logic based on whether certain conditions—such as the presence of other modules or specific environment variables—are met, failed, or skipped.

  • Adaptive Behavior: Automatically switch between features (e.g., enable Real-time Sync if inotify is present, otherwise fallback to Polling).
  • Safe Inter-Module Communication: Execute code that interacts with another module’s API only when that module is actually present and compatible.
  • System Transparency: Information about which optional features are active is displayed directly in the Administration UI.
  1. Ensure your module imports the necessary classes and interfaces from the framework:


  2. In your module() method, use the supports() method to register one or more support conditions.

    use Illuminate\Support\ServiceProvider;
    use Epsicube\Support\Contracts\IsModule;
    use Epsicube\Support\Enums\ModuleCondition;
    use Epsicube\Support\Modules\{Module,Supports,Support,Condition};
    class YourModule extends ServiceProvider implements IsModule
    {
    public function module(): Module
    {
    return Module::make('custom::my-module', '1.0.0')
    //...
    ->supports(fn (Supports $supports) => $supports->add(
    // Example: Conditional registration based on another module
    Support::forModule(
    identifiers: ['core::execution-platform' => '^1.0'],
    whenPass: fn () => Workflows::register(MyCustomWorkflow::make()),
    state: ModuleCondition::ENABLED,
    ),
    // Example: Adapting logic to the PHP environment
    Support::for(
    condition: Condition::all(
    Condition::phpExtensions('inotify'),
    Condition::phpExtensions('curl'),
    ),
    whenPass: $this->enableRealTimeSync(...),
    whenFail: $this->enablePollingSync(...),
    ),
    ));
    }
    //...
    }

The Condition helper provides several static methods to check the environment.

MethodDescription
phpVersion(string $version)Checks the current PHP version (e.g., ^8.2).
epsicubeVersion(string $version)Checks the version of the Epsicube Framework.
phpExtensions(string ...$ext)Checks if one or multiple PHP extensions are loaded.
MethodDescription
all(Condition ...$cond)AND logic: All conditions must be met.
any(Condition ...$cond)OR logic: At least one condition must be met.
when(Condition $cond, array $targets)Skips a list of conditions unless the first one is met.

When using Support::forModule(), the ModuleCondition enum defines the requirement:

StateUse Case
PRESENTSatisfied if the module exists, even if disabled. Great for class/file access.
ABSENTSatisfied only if the module is not installed. Ideal for avoiding conflicts.
ENABLEDSatisfied if the module is active. Use this when you need the module’s services.
DISABLEDSatisfied if the module is installed but turned OFF.
INACTIVESatisfied if the module is either missing OR disabled.
ACTIVEAlias for ENABLED.