Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tuxnix's avatar

Make:Resource Vs Make: Controller

I am working on building a Web App with an Admin facing back-end, that is mainly laravel 7 and JS and a PWA client side app that is HTML 5, CSS, and JS. I am new to laravel and a little confused from reading the documentation and some stack overflow posts on when it is best or when I should make an api resource class vs a controller class.

My question is, what is the difference between resources and controller classes and what is the best practice for when to use them?

Would I use the controller classes strictly for the Admin facing CRUD and resource class for sending and retrieving JSON data from the back-end? It seems like they both can be used either way.

0 likes
3 replies
ftiersch's avatar

make:resource will create an API resource. Not the same thing as resource controllers!

API Resources are used to transform the responses of APIs in a uniform value, you still need a controller to return them.

1 like
tuxnix's avatar

Thank you for the quick response!

So I would use the make:resource className file to transform my data to JSON lets say and then the make:controller className file would handle the rest of the work?

ftiersch's avatar

The JSON is handled automatically but you can transform the data.

Quick example... Let's say you have a blogpost and sometimes you want only certain parts of the posts (title + shortened text for a list view for example) and on the details view you need the whole post.

You could have a ListBlogPostResource and a BlogPostResource to handle that transformation of data from the same BlogPost model. That way the transformation is always the same if you need to do it in multiple places (for example a search endpoint or something like that).

The endpoints are still handled by controllers though, that is correct :)

Please or to participate in this conversation.