Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Symfony API Platform Operations

Hi right now I trying out API Platfom and when I try to restrict the collectionOperations I get an error.

can tell me why I get this error?

Unknown named parameter $collectionOperations

Code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<?php

namespace App\Entity;


use ApiPlatform\Metadata\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/** 
 * A message
 * 
 * @ORM\Entity
 */
#[ApiResource(
    collectionOperations: [
        'get'
    ]
)]

>Solution :

collectionOperations is not available in ApiPlatform v3, but was part of v2. The code should now look like this:

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;

#[ApiResource(operations: [
    new GetCollection()
])]

Have a look at their documentation for more details.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading