API Platform for Laravel: My First Impression

preview_player
Показать описание
If you want to generate the API quickly from just Eloquent Model, there's a new tool for that. I've tried it out.

Links mentioned in the video:

API Platform, not OpenAPI (I said OpenAPI 4 times)
AGAIN: API Platform, not OpenAPI
OpenAPI platform again

- - - - -
Support the channel by checking out my products:

- - - - -
Other places to follow:
Рекомендации по теме
Комментарии
Автор

Great comment from Kévin Dunglas himself, the creator. He replied on YouTube, but the comment seems to be hidden (too many links?).
Here it is:

"API Platform for Laravel is still quite new, and the docs is being improved. We still have a lot of work to do on this side.


You can customize this key (by using your own class for collection, or by registering a custom normalizer), but it's not a good idea because then you'll not be in sync with the spec, and client tools supporting this spec may not work as expected:


Supporting "Model::toArray()" is a good idea and should be easy to add. This will ease migrating from "API resources", we'll work on this. The recommended way to customize the fields in API Platform is to use the #[ApiProperty] attribute (you can change the name of the field, expose virtual fields, etc).


For versioning, while we encourage using an evolution-based strategy instead, you can use the router to add a prefix to all routes, or just use a custom URL including the version prefix by passing it as the first parameter of the #[ApiResource] attribute (but we need to document that better)."

LaravelDaily
Автор

I have been using API Platform for years with Symfony and loved it. I also like that it is compliant with Hydra standard - it might look strange at first but down the line I like the format, it is more descriptive, but you can also use normal json responses if you're not into it. Also adding /v1 to route is easily possible, at least I used that on one of projects on Symfony it was just a config setting.

Автор

As a developer whom worked a lot with Laravel it's very important to be able to do custom things. There's always something custom with either the business logic, existing database/codebase or other libraries from backend or frontend. Either we like it or not we don't live in a perfect world, so we always need to be able to adapt the libraries we use.

iedi
Автор

excited for them to release attribute support. Very surprised it wasnt available out of the gate. I know they have a some solutions merged with their 4.0 branch, but not actually released yet

MarkChaney
Автор

Nice to know for the simple update/create. Although I'm using V1 in the path of my biggest API project...

Are there any filters or relationship parameters for the index/list endpoint?

stephenr
Автор

you can get the typical Laravel api response by uncommenting jsonapi in the formats key in api-platform.php in config

xshaheen
Автор

Overall it looks good but fir advanced things we should dig deeper for it

shahsawoodshinwari
Автор

Great review. Could you mention alternative packages or approaches to update/enrich a current project with API features?

kengraversen
Автор

I have followed your Mini CRM tutorial, and of course I want to develop the API for the mobile app. But from this video, I think API Platform is not the good choice because of the limitation and "weird way" you mentioned. So, what are the other good choice to develop the API for Mini CRM?

angga.studio
Автор

in laravel 11 i suffer to make api auth with sanctum, and i saw a vedio in ur channel talking about that they removed kernal.php and the index.php is the alternate and you press on the functions inside that class it goes to the implementation of that function and i tried to do that but with vscode it doesn't work

iconicae
Автор

It looks very nice and you get so much with so little effort. However, I really hate that it is so closely tied to the models. I don't want every resource to be 1:1 mapped to my models. There needs to be some kind of layer between the models and the endpoints.

Pekzr
Автор

Allow me to ask a question outside the text 😅

Is it advisable to implement unit tests for standard operations, such as CRUD operations, in applications ؟

alihassan-qgky
Автор

It looks good and great but can we add different methods? It only works for crud operation. Is it possible to add methods like getCustomerDetail or something? If it's possible, where do we write it? or did it detect from the controller methods?

abelgetu
Автор

sir, can u just click that 'new chrome available' button on up right corner for an update. appreciate that... 😅

zulukll
Автор

There are many issues with laravel. It's amazing and powerful for small projects.

assemalwaseai
Автор

I Love your vids, please, update your browser Povilas. :D:D:D:D

brianochieng
Автор

what is that mysql app that he's using ?

mamad-dev
Автор

Looks nice, but in real life APIs usually contains way more complex logic...

linasgutauskas
Автор

Please, please if you're reading this: Api Platform is a good tool, but don't just expose your models to the world; once your API gets beyond the prototyping stage you'll regret how massively snarled the model will become. Use Dtos just like you would on a regular API

thirdvectr
Автор

Creating APIs with Laravel is so simple that I found it somewhat unnecessary, an excessive abstraction for something that isn't complicated to do in vanilla Laravel.

aleAmosin