Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop needing to cache:clear every Api Platform annotation change #16259

Closed
netrising opened this issue May 14, 2024 · 1 comment
Closed

Stop needing to cache:clear every Api Platform annotation change #16259

netrising opened this issue May 14, 2024 · 1 comment
Labels
API APIs related issues and PRs.

Comments

@netrising
Copy link

Sylius version affected: 1.13.0

Description
My problem is that every change that I got in annotations, I need to input cache:clear or cache:pool:clear to see my changes i.e (Adding serialization groups, adding attributes to @ApiResource annotation etc.).
I'm using PHP 8.3. Dev environment of course.

Steps to reproduce
Add ApiPlatform\Core\Annotation\ApiResource to any custom entity. Example code below:

<?php

declare(strict_types=1);

namespace App\Entity\Menu;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Wemea\SyliusMenuPlugin\Entity\Menu as BaseMenu;

#[ApiResource(
    routePrefix: '/shop',
    description: 'This resource is used to manage frontend Menus',
    collectionOperations: [
        'get'
    ],
    itemOperations: [
        'post'
    ]
)]
#[ORM\Entity]
#[ORM\Table(name: 'wemea_menu')]
class Menu extends BaseMenu

Possible Solution
use metadata_backward_compatibility_layer: false on api_platform.yaml as someone suggested, but unfortunately this will break the configuration with the following error:

The service "api_platform.metadata.resource.metadata_factory.yaml" has a dependency on a non-existent service "api_platform.metadata.extracto  
  r.yaml". Did you mean one of these: "api_platform.metadata.extractor.xml.legacy", "api_platform.metadata.extractor.yaml.legacy", "api_platfor  
  m.metadata.resource_extractor.xml", "api_platform.metadata.property_extractor.xml", "api_platform.metadata.resource_extractor.yaml", "api_pla  
  tform.metadata.property_extractor.yaml"?  

@GSadee GSadee added the API APIs related issues and PRs. label May 17, 2024
@GSadee
Copy link
Member

GSadee commented May 17, 2024

Hi @netrising!

This problem definitely seems to be caused more by the API Platform or Symfony. From the perspective of Sylius, we use APIP and nothing on our side changes the way configurations are cached.

As for the flag you mentioned, in Sylius 1.x it has to be enabled because of the way resources are configured. In version 2.0 only, we will use the new metadata from API Platform, perhaps the behaviour will be different there.

According to the above, I'm closing the issue 🖖🏻

@GSadee GSadee closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API APIs related issues and PRs.
Projects
None yet
Development

No branches or pull requests

2 participants