Adding Dependencies
Dependencies allow a module to require other modules to be enabled and within a compatible version before it can function.
This ensures that your module operates in a stable environment where its prerequisites are met.
By declaring dependencies, you can:
- Guarantee that shared functionality or services provided by other modules are available.
- Prevent fatal errors or misbehavior caused by missing components.
- Control the activation order of modules in a predictable way.
How to add dependencies ?
Section titled “How to add dependencies ?”-
Configure your module
Section titled “Configure your module”Your module must import the
Epsicube\Support\Modules\Dependenciesclass.use Illuminate\Support\ServiceProvider;use Epsicube\Support\Contracts\IsModule;use Epsicube\Support\Modules\{Module,Dependencies};class BrandingModule extends ServiceProvider implements IsModule{// ...public function module(): Module{return Module::make('custom::mycustommodule', '0.0.1')//...->dependencies(function(Dependencies $dependencies) {$dependencies->module('target-module', '^2.0');$dependencies->module('target-module2', '*'); // Any version (default)});}} -
Versioning Format (Semver)
Section titled “Versioning Format (Semver)”The versioning system follows the Semver format, exactly like Composer. You can use the full range of version constraints:
1.2.3: An exact version.^1.2: Any version greater than or equal to 1.2.0 and less than 2.0.0.>=5.0 <6.0: A specific range of versions.*: Any available version.
-
Understand Constraints
Section titled “Understand Constraints”