PHP code example of halloverden / request-mapping-bundle

1. Go to this page and download the library: Download halloverden/request-mapping-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

halloverden / request-mapping-bundle example snippets


// config/bundles.php

return [
    // ...
   HalloVerden\RequestMappingBundle\HalloVerdenRequestMappingBundle::class => ['all' => true],
];

    
    
    namespace App\Controller;
    
    use App\Entity\Requests\TestRequest;
    use App\Entity\Response\TestResponse;
    use HalloVerden\RequestMappingBundle\Attribute\MapRequestPayload;
    use Symfony\Component\HttpFoundation\JsonResponse;
    use Symfony\Component\Routing\Annotation\Route;
    
    #[Route(path: '/test2', name: 'testpost', methods: [Request::METHOD_POST])]
    class Test2Controller extends AbstractResponseEntityController {
      public function __invoke(
        #[MapRequestPayload(handler: 'your_handler')]
        TestRequestPayload $testRequestPayload
      ): JsonResponse {
        // Do something with $testRequestPayload
        return new JsonResponse();
      }
    }