PHP code example of stfalcon-studio / api-bundle

1. Go to this page and download the library: Download stfalcon-studio/api-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/ */

    

stfalcon-studio / api-bundle example snippets


# config/bundles.php

return [
    // Other bundles...
    StfalconStudio\ApiBundle\StfalconApiBundle::class => ['all' => true],
    // Other bundles...
];

#[Route(path: '/foo/bar', name: 'foo_bar', methods: [Request::METHOD_GET])]
public function __invoke(): JsonResponse
{
    // ...

    return new JsonResponse(data: $this->serializer->serialize(FooBar::cases()), json: true);
}

$this->serializer->serialize($fooBar, 'json', ['default_normalization' => true]);