Registering Options
Modules can be extended with customizable options, enabling developers to configure settings or adapt features without modifying the module’s core code.
Options can be managed either via the CLI or the Administration interface. For detailed usage, see Manage Options.
How to declare your options ?
Section titled “How to declare your options ?”-
Implement the Interface
Section titled “Implement the Interface”Your module must implement the
Epsicube\Support\Contracts\HasOptionsinterface.use Epsicube\Support\Contracts\HasOptions;use Epsicube\Schemas\Properties\StringProperty;use Epsicube\Schemas\Schema;class ExternalApiModule extends ServiceProvider implements HasOptions, Module{//...public function options(Schema $schema): void{$schema->append(['api_token' => StringProperty::make()->title('Api Token')->default('XXX-XXXXX-XXX'),]);}} -
Understand Options Schema
Section titled “Understand Options Schema”Each option is defined through a declarative Schema, which specifies the field types, default values, and the rules applied when options are read or updated.
The Schema acts as a centralized layer of description: it formalizes the structure of your configuration and ensures consistent behavior across both the CLI and the Administration interface.
For an in-depth overview of available field types, validation mechanisms, and advanced behaviors, refer to the dedicated section: Defining Schemas.
-
Use Your options
Section titled “Use Your options”The
Optionsfacade allows you to retrieve, update, and delete options for your module:use Epsicube\Support\Facades\Options;// Retrieve all options for a moduleOptions::all('your-module-identifier');// Retrieve a specific optionOptions::get('your-module-identifier', 'api_token');// Update an optionOptions::set('your-module-identifier', 'api_token', 'new_value');// Delete an option to revert to defaultOptions::delete('your-module-identifier', 'api_token');