dariotilgner/liform
Serialize Symfony Forms into JSON Schema for documentation, validation, and client-side form generation. Works with generators like liform-react or json-editor, and powers LiformBundle. Use as a standalone library to keep backend and frontend forms in sync.
symfony/form, symfony/validator) make integration feasible with minimal overhead. Laravel’s Form Requests or API Resources could leverage this for schema generation.symfony/form (≥5.0) and symfony/validator (≥5.0). Laravel already bundles these via illuminate/support (indirectly).Form::macro() or collective/html diverge from Symfony’s FormBuilder. May need a wrapper to normalize form definitions.Validator uses a different rule syntax (e.g., required|email). Requires translation logic (e.g., required → "type": "string", "pattern": "^[^@]+@[^@]+\.[^@]+$" for email).FormRequest or Livewire forms may need adaptation to Symfony’s FormType structure.| Risk Area | Severity | Mitigation |
|---|---|---|
| Schema Accuracy | High | Validate generated schemas against test cases (e.g., edge cases like nested forms). |
| Performance Overhead | Medium | Benchmark schema generation for complex forms (e.g., 50+ fields). |
| Maintenance Burden | Medium | Monitor Symfony Form updates for breaking changes (e.g., PHP 8.2+ features). |
| Laravel-Symfony Gaps | High | Build a facade/wrapper to abstract Symfony-specific logic (e.g., FormType → Laravel FormRequest). |
| Frontend Integration | Low | Ensure schema output aligns with frontend tooling (e.g., OpenAPI/Swagger compatibility). |
FormRequest classes be adapted to Symfony FormType, or is a custom wrapper needed?Validator rules map to JSON Schema constraints?symfony/form and symfony/validator under the hood (via illuminate/support). No additional composer dependencies are strictly required if using Laravel’s built-in components.Form facade (though limited).FormRequest → FormType).useForm in Inertia).zircote/swagger-php).FormRequest classes, Livewire components) to identify compatibility gaps.FormType logic:
// Example: liform-facade/src/Liform.php
class Liform {
public static function fromFormRequest(FormRequest $request): string {
$formType = self::convertRequestToFormType($request);
return (new \Dariotilgner\Liform\Liform())->render($formType);
}
}
Validator rules to JSON Schema constraints (e.g., required|email → "type": "string", "format": "email").| Laravel Feature | Compatibility | Workaround |
|---|---|---|
| Form Requests | Low (different structure) | Write a converter to transform FormRequest to FormType. |
| Eloquent Model Binding | Medium | Use FormType extensions to bind to Eloquent models. |
| Livewire Components | High (schema as prop) | Pass schema as a Livewire prop to frontend. |
| API Resources | Medium | Generate schema from FormRequest used in APIResource. |
| Validation Rules | Low (syntax mismatch) | Build a rule-to-schema mapper (e.g., `required |
| Localization | Medium | Extend Liform to support Symfony’s translation system. |
FormRequest classes to FormType and generate schemas.illuminate/support bundles symfony/form (v5.x). Upgrade risks:
composer.json or use a wrapper to isolate changes.How can I help you explore Laravel packages today?