PHP code example of grzegorz-jamroz / sf-storage-api-bundle
1. Go to this page and download the library: Download grzegorz-jamroz/sf-storage-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/ */
grzegorz-jamroz / sf-storage-api-bundle example snippets
declare(strict_types=1);
namespace App\Controller;
use App\Entity\Product;
use App\Storage\ProductStorage;
use Ifrost\StorageApiBundle\Attribute\StorageApi;
use Ifrost\StorageApiBundle\Controller\StorageApiController;
#[StorageApi(entity: Product::class, storage: ProductStorage::class, path: 'products')]
class ProductController extends StorageApiController
{
}
declare(strict_types=1);
namespace App\Controller;
use App\Entity\Product;
use App\Storage\ProductStorage;
use Ifrost\StorageApiBundle\Attribute\StorageApi;
use Ifrost\StorageApiBundle\Controller\StorageApiController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[StorageApi(entity: Product::class, storage: ProductStorage::class, path: 'products')]
class ProductController extends StorageApiController
{
#[Route('/create_products', name: 'products_create', methods: ['POST'])]
public function create(): Response
{
return $this->getApi()->create();
}
}
declare(strict_types=1);
namespace App\Controller;
use App\Entity\Product;
use App\Storage\ProductStorage;
use Ifrost\StorageApiBundle\Attribute\StorageApi;
use Ifrost\StorageApiBundle\Controller\StorageApiController;
use Ifrost\ApiFoundation\Enum\Action;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[StorageApi(
entity: Product::class,
storage: ProductStorage::class,
path: 'products',
excludedActions: [
Action::CREATE,
Action::UPDATE,
Action::MODIFY,
'delete',
'not_valid_actions_will_be_omitted'
])]
class ProductController extends StorageApiController
{
}
php bin/console debug:router
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.