bu/extra-param-converter-bundle
Installation:
composer require bu/extra-param-converter-bundle dev-master
Ensure SensioFrameworkExtraBundle is installed and enabled (sensio_framework_extra.request.converters: true in config).
Register Bundle:
Add to AppKernel.php:
new Bu\ExtraParamConverterBundle\BuExtraParamConverterBundle(),
First Use Case:
Convert a GET parameter (?id=1) to an entity in a controller:
use App\Entity\User;
public function showAction(User $user) { ... }
The bundle auto-resolves User from the id GET parameter.
?name=John to $name = "John".?user=123 to User entity via find() (throws NotFoundHttpException if missing).?users[]=1&users[]=2 → Collection<User> (requires Doctrine\Common\Collections\Collection type-hint).Example:
public function listAction(Collection $users) { ... } // Converts ?users[]=1&users[]=2
User from POST['name']).application/json requests into objects/arrays.
public function createAction(User $user) { ... } // $user populated from JSON POST body
Bu\ExtraParamConverterBundle\Converter\ConverterInterface for domain-specific logic.use Symfony\Component\Validator\Constraints as Assert;
public function updateAction(
#[Assert\Type(type: User::class)]
User $user
) { ... }
POST['address'] → Address entity).Missing SensioFrameworkExtraBundle:
No converter found for argument.sensio_framework_extra.request.converters: true in config.yml.Entity Not Found:
NotFoundHttpException for missing entities (e.g., ?user=999999).UserRepository::find() logic.JSON Parsing:
Content-Type: application/json is missing.#[ParamConverter("json")] annotation or ensure headers are set.debug:router or debug:container to inspect converters.Bu\ExtraParamConverterBundle\EventListener\ParamConverterListener to log conversions.Custom Naming Strategies:
Override Bu\ExtraParamConverterBundle\Converter\GetConverter to change how parameters map to entity methods (e.g., ?username=john → findByUsername()).
Strip Tags: Enable HTML stripping for GET/POST via config:
bu_extra_param_converter:
strip_tags: true
Performance:
Cache entity lookups for high-traffic endpoints (e.g., find() with @Cache in Doctrine).
How can I help you explore Laravel packages today?