- Is cesurapp/api-bundle compatible with Laravel?
- No, cesurapp/api-bundle is built for Symfony 8+ and relies on Symfony components such as HttpFoundation, Validator, Dependency Injection, and Doctrine. Laravel integration would require custom bridges or a hybrid architecture rather than a drop-in install. You can borrow its API patterns, but expect significant adaptation work in a Laravel codebase.
- How do I install cesurapp/api-bundle?
- Install it with composer require cesurapp/api-bundle. The package requires Symfony 8+ and PHP 8.1 or newer. After installation, create config/packages/api.yaml to configure exception conversion, CORS headers, and Thor documentation settings. In Laravel, Composer may install the package, but framework wiring and service configuration will not work automatically.
- What features does cesurapp/api-bundle provide for API development?
- It provides JSON request body transformation, unified and translatable error messages, CORS header support, DTO resolution with auto-validation, and Doctrine filter and sorter resources. It also includes a Thor documentation generator, a TypeScript client generator, custom validators, and Excel or CSV export support. Most features are designed around Symfony conventions and Doctrine.
- Can I use cesurapp/api-bundle DTO validation in Laravel?
- The bundle uses Symfony Validator and includes custom validators such as PhoneNumber, UniqueEntity, and Username. Laravel's FormRequest or Validator facade could theoretically wrap Symfony's validator through a container bridge, but the custom validators would need Laravel-specific implementations. This is not plug-and-play and may duplicate validation logic across both frameworks.
- Does cesurapp/api-bundle support Doctrine filtering, and can I use it with Eloquent?
- Yes, the bundle includes Doctrine filter and sorter resources for building filtered API queries. There is no Eloquent adapter, so Laravel users would need to manually translate Doctrine QueryBuilder filters to Eloquent. That translation carries risks around SQL injection and query performance if not handled carefully.
- How does cesurapp/api-bundle handle error messages and translation?
- It collects error messages under a single format and applies language translation to all error messages. Symfony's ExceptionConverter is used to standardize exceptions, and CORS headers are configured through the cors_header YAML settings. In Laravel, you would need to map this behavior into App\Exceptions\Handler or custom middleware to keep responses consistent.
- Can cesurapp/api-bundle generate TypeScript clients and API docs in Laravel?
- The bundle generates API documentation through Thor and can extract a TypeScript client using bin/console thor:extract. Thor assumes Symfony routing attributes and Symfony console commands, so Laravel would require a rewrite or proxy layer. You could adapt the generated output alongside Laravel tools such as l5-swagger, but it is not a direct integration.
- What are the Laravel alternatives to cesurapp/api-bundle?
- For Laravel-native API development, consider spatie/laravel-api for simpler API scaffolding, darkaonline/l5-swagger for OpenAPI documentation, and Laravel FormRequest plus API Resources for validation and transformation. For exports, spatie/array-to-xlsx or maatwebsite/excel are more straightforward than Symfony-oriented export bundles. These alternatives avoid Symfony dependency overhead in a Laravel application.
- What are the production risks of using cesurapp/api-bundle in a Laravel app?
- The main risks are Symfony dependency overhead, version conflicts between Symfony 8+ and Laravel's component constraints, and the need to translate Doctrine filters to Eloquent. Custom validators and Thor routing assumptions would also require reimplementation or proxy layers. The package has low stars and a recent release, so edge cases may need custom fixes; piloting admin endpoints first is sensible.
- What Symfony and PHP versions does cesurapp/api-bundle require?
- The package requires Symfony 8 or newer and PHP 8.1 or newer. Those constraints may overlap with Laravel's PHP support window but can conflict with the Symfony component versions Laravel depends on. Check Composer constraints carefully before adding it to an existing Laravel project.