1

The documentation says that there is file api/config/api_platform/resources.yaml where I can map entities using yml. But neither in the distribution nor when I install API-platform as a package I can't find this file. Creation of the directory and file manually doesn't help.

A.L
  • 10,259
  • 10
  • 67
  • 98

1 Answers1

3

In the context of a Symfony 4 project, the file can be located at config/api_platform/resources.yaml. If it doesn't exist, simply create it.

You can also use several files in order to define your mappings:

  • config/api_platform/resources/entity1.yaml
  • config/api_platform/resources/entity2.yaml

I suggest to use separate files since it's simpler to maintain than one big file.

You'll have to configure these paths in the config/packages/api_platform.yaml file:

api_platform:
    mapping:
        paths: ['%kernel.project_dir%/config/api_platform/resources']

See Nek's answer for a complete example.


I find the documentation a little bit confusing about this, because in a Symfony project there's no api/ directory at the root of the project.

A.L
  • 10,259
  • 10
  • 67
  • 98