Installation

We assume you're familiar with Composerarrow-up-right, a dependency manager for PHP. Use the following command to add the bundle to your composer.json and download the package.

If you have Composer installed globallyarrow-up-right.

composer require sylius/resource-bundle

Otherwise, you have to download .phar file.

curl -sS https://getcomposer.org/installer | php
php composer.phar require sylius/resource-bundle

Adding Required Bundles to The Kernel

You need to enable the bundle and its dependencies in the kernel:

config/bundles.php
return [
    new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
    new BabDev\PagerfantaBundle\BabDevPagerfantaBundle(),
];

Configure your mapping paths for your resources :

config/packages/sylius_resource.php
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    $containerConfigurator->extension(
    namespace: 'sylius_resource',
     config: [
        'mapping' => [
            'paths' => [
                '%kernel.project_dir%/src/Entity',
            ],
        ],
        'resources' => null,
    ]);
};

Configure the routing

That's it! Now you can configure your first resource.

Last updated

Was this helpful?