// composer.json
{
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^3.0", // v3.0.8
"doctrine/annotations": "^1.0", // 1.14.2
"doctrine/doctrine-bundle": "^2.8", // 2.8.0
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.2.2
"doctrine/orm": "^2.14", // 2.14.0
"nelmio/cors-bundle": "^2.2", // 2.2.0
"nesbot/carbon": "^2.64", // 2.64.1
"phpdocumentor/reflection-docblock": "^5.3", // 5.3.0
"phpstan/phpdoc-parser": "^1.15", // 1.15.3
"symfony/asset": "6.2.*", // v6.2.0
"symfony/console": "6.2.*", // v6.2.3
"symfony/dotenv": "6.2.*", // v6.2.0
"symfony/expression-language": "6.2.*", // v6.2.2
"symfony/flex": "^2", // v2.2.4
"symfony/framework-bundle": "6.2.*", // v6.2.3
"symfony/property-access": "6.2.*", // v6.2.3
"symfony/property-info": "6.2.*", // v6.2.3
"symfony/runtime": "6.2.*", // v6.2.0
"symfony/security-bundle": "6.2.*", // v6.2.3
"symfony/serializer": "6.2.*", // v6.2.3
"symfony/twig-bundle": "6.2.*", // v6.2.3
"symfony/ux-react": "^2.6", // v2.6.1
"symfony/validator": "6.2.*", // v6.2.3
"symfony/webpack-encore-bundle": "^1.16", // v1.16.0
"symfony/yaml": "6.2.*" // v6.2.2
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4", // 3.4.2
"symfony/debug-bundle": "6.2.*", // v6.2.1
"symfony/maker-bundle": "^1.48", // v1.48.0
"symfony/monolog-bundle": "^3.0", // v3.8.0
"symfony/stopwatch": "6.2.*", // v6.2.0
"symfony/web-profiler-bundle": "6.2.*", // v6.2.4
"zenstruck/foundry": "^1.26" // v1.26.0
}
}
// composer.json
{
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^3.0", // v3.0.8
"doctrine/annotations": "^1.0", // 1.14.2
"doctrine/doctrine-bundle": "^2.8", // 2.8.0
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.2.2
"doctrine/orm": "^2.14", // 2.14.0
"nelmio/cors-bundle": "^2.2", // 2.2.0
"nesbot/carbon": "^2.64", // 2.64.1
"phpdocumentor/reflection-docblock": "^5.3", // 5.3.0
"phpstan/phpdoc-parser": "^1.15", // 1.15.3
"symfony/asset": "6.2.*", // v6.2.0
"symfony/console": "6.2.*", // v6.2.3
"symfony/dotenv": "6.2.*", // v6.2.0
"symfony/expression-language": "6.2.*", // v6.2.2
"symfony/flex": "^2", // v2.2.4
"symfony/framework-bundle": "6.2.*", // v6.2.3
"symfony/property-access": "6.2.*", // v6.2.3
"symfony/property-info": "6.2.*", // v6.2.3
"symfony/runtime": "6.2.*", // v6.2.0
"symfony/security-bundle": "6.2.*", // v6.2.3
"symfony/serializer": "6.2.*", // v6.2.3
"symfony/twig-bundle": "6.2.*", // v6.2.3
"symfony/ux-react": "^2.6", // v2.6.1
"symfony/validator": "6.2.*", // v6.2.3
"symfony/webpack-encore-bundle": "^1.16", // v1.16.0
"symfony/yaml": "6.2.*" // v6.2.2
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4", // 3.4.2
"symfony/debug-bundle": "6.2.*", // v6.2.1
"symfony/maker-bundle": "^1.48", // v1.48.0
"symfony/monolog-bundle": "^3.0", // v3.8.0
"symfony/stopwatch": "6.2.*", // v6.2.0
"symfony/web-profiler-bundle": "6.2.*", // v6.2.4
"zenstruck/foundry": "^1.26" // v1.26.0
}
}
¿Necesitas crear una API y te encanta el proceso? Has venido al lugar adecuado.
Construida sobre Symfony, API Platform te permite crear una API hipermedia, rica y basada en JSON-LD... prácticamente al instante (incluso te enseñaremos qué significan esas palabras de moda). En este tutorial, construiremos una aplicación real que incluye:
ApiResource
Haha, quite "averagely", I would agree! Looking at all the old syntax - the annotations, etc - no fun. We're going to get these out as quickly as we can - I've nearly got all of the audio recorded (and all the video is already done).
Cheers!
Hello!
Thank you very for the tutos.
At the moment I'm trying to set an offset (using offset instead of page), but I cannot override the actual pagination (I cannot setFirstResults of the queries), any ideas plz ?
Hey @May-S
Thanks for your kind words. About your question, I'm not sure what you mean by "using an offset" but have you read the last topics of the documentation? https://api-platform.com/docs/core/pagination/#controlling-the-behavior-of-the-doctrine-orm-paginator
I believe you'll need to extend or create a custom paginator
Cheers!
Thanks. Though why no information about new state providers?
At the moment I'm struggling to use Custom DataProvider with DTO to GetCollection data.
I manage to get the data, but the pagination info is gone :(
Hey @Rokas-P!
Unfortunately, custom data providers will be covered, but not until episode 3. If you're trying to customize how a collection of entities is returned, then you should use a query extension instead. If this is a more custom source, I haven't done this yet, but you can look at how the ORM pagination works. The process is:
A) CollectionProvider
is the provider used for the ORM: https://github.com/api-platform/core/blob/main/src/Doctrine/Orm/State/CollectionProvider.php
B) At first, it looks like there is nothing related to pagination, and this returns the final result on the bottom. BUT, just above the bottom, it checks to see if any extensions implement QueryResultCollectionExtensionInterface
. And they do, it calls them and returns THAT result instead. This is a sneaky way of calling PaginationExtension
: https://github.com/api-platform/core/blob/main/src/Doctrine/Orm/Extension/PaginationExtension.php
C) PaginationExtension::getResult()
returns a Paginator
object. THAT is the key.
So the long story is that, if you want your custom data provider to allow pagination, instead of returning the array of results, you should return a Paginator
. Well, not THAT Paginator
, as that's from the ORM. I think you'll need to create a custom class that implements PaginatorInterface
(or more likely extends AbstractPaginator
).
Let me know if this helps :).
Cheers!
Thanks Ryan, nice start !
Any chance to see a tutorial about client generator for nuxt 3 ?
Very nice! Thanks for the good work! Is there any chance you'll be doing an upgrade guide from 2.6/2.7 to >3 like you did for Symfony 5.* to 6? That one helped me a loooot :)
Hey Martin!
Hmm, maybe! I have one other friend that is doing the upgrade on a pretty big project and has been hitting some issues. Are there any specific things with upgrading that you're interested in? Or just a general request because you'll need to upgrade an app at some point?
Cheers!
Hy Ryan,
sorry for the late answer.
I'm working on a project with multiple Microservices which are based on Symfony 5.4 and Api-platform 2.7. These will have to be upgraded to Symfony6 and Apip3 sooner or later. In my opinion better sooner than later. The heavy lifting was done in the upgrade from 2.6. to 2.7 with the new syntax, but there are some deprecations I just don't seem to get rid off.
And that's the point where your upgrading symfony course really helped me and I would have the hopes, that upgrading apip would do the same :D
for example:
Since api-platform/core 2.7: The $exceptionOnNoToken parameter in "ApiPlatform\Symfony\Security\ResourceAccessChecker::__construct()" is deprecated and will always be false in 3.0, you should stop using it.
Ignore that deprecation in my last comment. I upgraded to Symfony 6.2 and apip 3.1 just to see if it works and this and another deprecation just went away. A bit jarring for me, because I don't have that much Symfony experience, but sometimes you just have to try.
Nice work Martin! That deprecation indeed looks odd. The deprecations system in Symfony is GREAT, but sometimes they're a bit internal and it's not obvious what's needed :)
Thank you very much, Ryan - the guide fell from heaven! A few days ago I was just watching the previous version of the guide to the API Platform but with symfony 6.2 it worked quite averagely! I'm waiting for the next episodes! :)