mcfedr/json-form
Symfony bundle/trait that lets controllers handle forms submitted as JSON. Use JsonControllerTrait to create and process JSON-backed forms, accepting payloads shaped like normal form fields, then validate and persist as usual.
Illuminate\Html\FormBuilder or collective/html). However, if JSON payloads are used for API-driven forms (e.g., frontend JS → backend API), this could be a viable workaround with abstraction layers.laravel-form-builder or custom validation logic (e.g., Validator facade) may reduce dependency on this package.symfony/http-foundation) or where JSON-form submissions are a core requirement.Symfony\Component\Form) would need explicit inclusion.form and validator components, which may bloat the project if unused elsewhere. Alternatives like Laravel’s Request validation or API resource classes could mitigate this.FormRequest or ApiResource may suffice for most use cases.Validator, FormRequest).Why Symfony Forms?
Validator or FormRequest achieve the same goal with less overhead?JSON Form Use Cases
Long-Term Strategy
Performance Impact
symfony/form, symfony/validator, and related bundles (e.g., symfony/yaml). Conflict risk if Laravel already uses Symfony packages (e.g., symfony/http-client).Illuminate\Validation\Validator with custom rules or FormRequest classes.Request validation.spatie/laravel-data) or API resources.ValidateRequests). Custom middleware would be needed to bridge the gap.FormFactory) assume Symfony’s routing system. Laravel’s routing would require adapters or wrapper classes.VerifyCsrfToken middleware.composer require symfony/form symfony/validator symfony/yaml
FormFactory.use Symfony\Component\Form\FormFactoryInterface;
class SymfonyFormService {
public function __construct(private FormFactoryInterface $factory) {}
public function createForm(array $data) {
// Symfony form logic here
}
}
use App\Services\SymfonyFormService;
class JsonFormController {
public function store(SymfonyFormService $formService, Request $request) {
$form = $formService->createForm($request->json()->all());
if ($form->isSubmitted() && $form->isValid()) {
// Process data
}
return response()->json($form->getErrors());
}
}
DoctrineBridge vs. Laravel’s Eloquent).platform-check or why-not to detect risks.FormType, FormBuilder).FormRequest integration).How can I help you explore Laravel packages today?