- Can I install tbbc/rest-util-bundle in a Laravel application?
- No. It is a Symfony bundle that ships a Bundle subclass, a DI extension, and service configuration that registers listeners against Symfony's kernel.request and kernel.response events. Laravel has no bundle concept and no kernel event model that maps onto those listeners, so Composer may download files but nothing will actually be wired up. Treat it as a readable design reference only, not a dependency.
- Which Laravel versions does tbbc/rest-util-bundle support?
- None. The package targets Symfony 2-era applications and ships no Laravel service provider, facade, or config file. Assume it is incompatible with Laravel 10 and 11, and with PHP 8.2 and 8.3, until proven otherwise. Proving otherwise costs more than simply writing the equivalent middleware.
- What does tbbc/rest-util-bundle actually do?
- It wires the tbbc/rest-util library into a Symfony kernel, providing base controller utilities, JSON response helpers, Accept-header content negotiation, and consistent error handling. The real logic lives in the library's request and response listeners, which the bundle registers as kernel event subscribers. Outside a Symfony kernel there is nothing for it to hook into.
- How do I do content negotiation in Laravel instead?
- Write a single middleware around willdurand/negotiation, which is actively maintained, framework-agnostic, and PHP 8 compatible. Resolve the Accept header to a format, return a 406 response when nothing matches, and store the resolved format on the request for later use. Pair it with Laravel API Resources or spatie/laravel-fractal to shape the payload for each format.
- Is tbbc/rest-util-bundle still maintained and PHP 8 compatible?
- The signals are uniformly negative: roughly 30 stars, zero dependents, a very low composite score, and a Symfony 2 lineage that implies PHP 5.x APIs such as getRequest() and possibly PSR-0 autoloading. There is no evidence of recent CI, security response, or maintainer activity. Assume it will not run on PHP 8.2 or later without patching.
- How do I replace the JSON response helpers from the bundle in Laravel?
- Use response()->json() behind a small base controller trait or a ResponseFactory macro so every endpoint returns the same envelope. Map exceptions to JSON in the exception handler configured in bootstrap/app.php. That covers the bundle's response-helper footprint in a couple of hours of work and produces code you own and can test.
- What are the best alternatives to tbbc/rest-util-bundle for Laravel APIs?
- Use willdurand/negotiation for Accept-header negotiation, Laravel API Resources or spatie/laravel-fractal for representation and transformation, and Laravel's exception handler for consistent error shapes. Add route prefixes or a versioning package if you need API versioning. None of these require a Symfony bundle or a legacy kernel scaffold.
- Can I use the tbbc/rest-util library directly without the Symfony bundle?
- Not cleanly. Its listeners are tied to Symfony's kernel.request and kernel.response events, so removing the bundle just moves the Symfony coupling into your own wiring code. If a specific behavior is genuinely valuable, read the listener source and reimplement the roughly 150 to 300 relevant lines under your own namespace with your own tests.
- How do I return a 406 Not Acceptable response in Laravel?
- Do it in middleware that runs before the controller: negotiate the Accept header and, when no acceptable type matches, return response()->json with a 406 status and a short error body. Register the middleware globally or on the API route group. Keep the error shape identical to your other API errors so clients can handle it uniformly.
- Is it worth porting tbbc/rest-util-bundle to Laravel?
- No, replace rather than port. Every layer of the bundle is Symfony-specific, so porting means rewriting the registration, DI, and event wiring anyway. Implement a negotiation middleware plus API Resources, and hand-copy only the specific format aliases or exception mappings you actually need. Vendoring an abandoned framework plugin imports the upgrade problem without solving it.