Skip to content
This documentation is in construction.

Export Schemas

A Schema can be transformed into different formats depending on your needs. This is handled by Exporters , which take a schema and produce output suitable for a specific format, or use case.

An Exporter is a class responsible for converting a schema into another representation.

  • It defines how each property of the schema should be translated.
  • It can apply defaults, validation rules, or UI-specific settings.
  • Multiple exporters can coexist, each targeting a different output (e.g., JSON, forms, CLI prompts).

Epsicube’s Schema system includes several built-in exporters, each designed to transform a schema into a specific format or usage context. Exporters do not modify the schema—they generate representations compatible with different systems.

The JsonSchemaExporter converts a schema into a standard JSON Schema format. This is useful for API documentation, validation, or front-end integrations.

Usage example:

use Epsicube\Schemas\Exporters\JsonSchemaExporter;
$jsonSchema = $schema->export(new JsonSchemaExporter);
// Or use the shortcut
$jsonSchema = $schema->toJsonSchema();

The FilamentExporter converts a schema into FilamentPHP forms or infolists, compatible with the Filament admin panel.

Usage example:

use Epsicube\Schemas\Exporters\FilamentComponentsExporter;
use Filament\Support\Enums\Operation;
$formComponents = $schema->export(new FilamentComponentsExporter(Operation::Edit)); // Or Operation::Create
$infolistComponents = $schema->export(new FilamentComponentsExporter(Operation::View));
// Or use the shortcut
$schema->toFilamentComponents($operation);

The LaravelPromptsFormExporter generates interactive CLI prompts based on your schema properties. It is ideal for creating command-line wizards, setup scripts, or guided input flows.

Usage example:

use Epsicube\Schemas\Exporters\LaravelPromptsFormExporter;
// Export schema as CLI prompts and execute them
$resultData = $schema->export(new LaravelPromptsFormExporter([
'username' => 'current' // Optional: pre-fill with current values
]));
// Shortcut method
$resultData = $schema->toExecutedPrompts([
'username' => 'current' // Optional: pre-fill values
]);

The LaravelValidationExporter converts a schema into Laravel validation rules that can be applied directly in $request->validate() or FormRequest classes.

This exporter provides a custom Validator instance that respects schema defaults and optional fields.


use Epsicube\Schemas\Exporters\LaravelValidatorExporter;
// Export validator
$validator = $schema->export(new LaravelValidatorExporter($data));
// Or use the shortcut
$validator = $schema->toValidator($data);
// Example usage in a FormRequest
$validated = $validator->validated();

When exporting rules, it is recommended to pass the current data as the first argument (e.g., $request->all()).

Some rules like array and object are dynamic and only apply based on the provided data.

$validator = $schema->toValidator($request->all());

You can provide an optional array of rules to prepend to all fields. For example, ['bail'] stops validation on the first failure:

$validator = $schema->toValidator($request->all(), prepend: ['bail']);