PHP code example of vim / symfony-api

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

    

vim / symfony-api example snippets



return [
  // ...
  Vim\Api\ApiBundle::class => ['all' => true],
];


declare(strict_types=1);

namespace App\Controller;

use Symfony\Component\Routing\Annotation\Route;
use Vim\Api\Attribute\Resource;
use Vim\Api\Attribute\Paginate;
use Vim\Api\Attribute\Filter;
use Vim\Api\Attribute\Hydrate;
use Vim\Api\Attribute\Validate;
use Vim\Api\Attribute\Flush;
use App\Entity\Post;

#[Route('/post')]
class PostController
{
    #[Route('')]
    #[Resource(Post::class)]
    #[Paginate]
    #[Filter\MultiSelect('category.group.id')]
    #[Filter\DateFrom('postedAt', 'postedAtFrom')]
    #[Filter\DateTo('postedAt', 'postedAtTo')]
    #[Filter\Like('content')]
    public function index(): void
    {
    }
    
    #[Route('', methods: ['POST'])]
    #[Resource('post')]
    #[Hydrate]
    #[Validate]
    #[Flush]
    public function create(Post $post): void
    {
    }

    #[Route('/{id}', methods: ['PUT'])]
    #[Resource('post')]
    #[Hydrate]
    #[Validate]
    #[Flush]
    public function update(Post $post): void
    {
    }

    #[Route('/{id}', methods: ['DELETE'])]
    #[Resource('post')]
    #[Flush]
    public function delete(Post $post): void
    {
    }
}