API Platform Crash Course Part 12: Subresources

preview_player
Показать описание
ℹ This is a crash course on the API Platform which is intended to get you writing your own API's as quickly as possible. In part 12, I'll show you how two different ways of accessing subresources e.g. Products which belong to a particular Manufacturer.

💻Source code here:

👇Follow me on Social Media:

💕Show support:

💻If you are just consuming your own API and you want traditional session authentication then check out this Symfonycasts tutorial:
Рекомендации по теме
Комментарии
Автор

I’d always just used a filter. Glad to know there’s another option. Thanks Gary!

peachesontour
Автор

One of the major benefits of subresources is to be able to add them from another resource with cascading persists. You can have as many nested subresources as you want and be able to create Country > Region > City all in one request. That is the real power of subresources, not just returning data.

fedorp
Автор

Hello, Gary. Using subresource in the filter doesn't work for me but marking it with [#ApiSubresource] works great.
My project is based on ApiPlatform 2.6, Symfony 6.1 and PHP 8.1 and I'm using PostgreSQL, not MySQL. Leaving it if anyone else also has problems with subresources in the filter.

veselinmihaylov