PHP code example of alexandrebulete / ddd-apiplatform-bundle

1. Go to this page and download the library: Download alexandrebulete/ddd-apiplatform-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/ */

    

alexandrebulete / ddd-apiplatform-bundle example snippets


return [
    // ...
    AlexandreBulete\DddApiPlatformBundle\DddApiPlatformBundle::class => ['all' => true],
];

use AlexandreBulete\DddApiPlatformBridge\State\Paginator;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;

class GetPostsProvider implements ProviderInterface
{
    public function __construct(
        private QueryBusInterface $queryBus,
    ) {}

    public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
    {
        $posts = $this->queryBus->ask(new GetPostsQuery(/* ... */));
        
        // Return Paginator for pagination support
        return new Paginator(/* ... */);
    }
}