Skip to content
This documentation is in construction.

Managing Requirements

Requirements are hard prerequisites that must be satisfied for a module to be enabled. Unlike Supports, which gracefully adapt the module’s behavior, Requirements will block the module from starting entirely if they are not met.

  • Prevention: Stop the module from running on incompatible environments.
  • Stability: Ensure critical system components are loaded before execution.
  • Complex Validation: Use logical operators to define sophisticated environmental needs.
  1. Ensure your module imports the necessary classes from the framework:


  2. Use the requirements() method in your module() definition. You can chain multiple conditions together.

    use Illuminate\Support\ServiceProvider;
    use Epsicube\Support\Contracts\IsModule;
    use Epsicube\Support\Modules\{Module, Requirements, Condition};
    class ImageProcessorModule extends ServiceProvider implements IsModule
    {
    public function module(): Module
    {
    return Module::make('image-processor', '1.1.0')
    ->requirements(fn (Requirements $requirements) => $requirements->add(
    // Base system prerequisite
    Condition::phpVersion('>= 8.2'),
    Condition::phpExtensions('fileinfo'), // Mandatory for MIME detection
    // The module needs at least one valid engine to function
    Condition::any(
    Condition::phpExtensions('gd'),
    Condition::phpExtensions('imagick'),
    Condition::all(
    Condition::phpExtensions('vips'),
    Condition::phpVersion('>= 8.3') // VIPS requires PHP 8.3+ here
    )
    ),
    // Conditional Requirement (Condition::when)
    // If 'imagick' is used, we strictly require PHP 8.3
    ...Condition::when(Condition::phpExtensions('imagick'), [
    Condition::phpVersion('>= 8.3'),
    ])
    ));
    }
    }
  3. The Condition helper provides several static methods to check the environment.

    These are the same conditions used in the Support system.

    See the Available Conditions.