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

Ronaldo100's avatar

Why @method('PUT') ?

Hello! :)

So, I am just re-watching a multiple hours long video on Laravel and I am still confused by "PUT" requests.

At first, the teacher showed how to create a new entry. That, I understood.

Then, the teacher went on to show how to EDIT the priorly added entry.

In order to do so, he first created a new route, then added a controller, and then copied over the "create entry" blade template to the new "edit blade template".

When he was editing the edit Blade template, he said, that we have to make this a PUT request as it's UPDATING an entry rather than creating a new entry.

So, he used when he CREATED an entry, but he wants to use PUT when updating the entry.

That's what's got me really confused. Why can't we use POST? Is this a Laravel specific thing?

Anyway, the teacher then proceeded to explain, that the tag would only accept GET or POST requests, so the teacher goes on to use the @method() directive in laravel like this:

<form method="post" action="/listings/{{$listing->id}}" enctype="multipart/form-data">

@csrf
@method('PUT')

Long story short: Whyyyyy do we need PUT at all?

I have never used any PUT requests in my whole life!

Please tell me this is some Laravel specific thing, or have I just wrongfully never used PUT requests my whole life?

Thanks

Ronaldo

0 likes
5 replies
jlrdw's avatar

Put and patch are for restful apis for better detail look over the symfony documentation. Somehow it seems that in laravel most people seems to think it's required all the time for editing which it is not.

When the database is on the same server and not being used as an API you can just use post.

Though put seems to do something, it doesn't, Symfony request just turns it into a post when a post is required.

Ronaldo100's avatar

@jlrdw So, long story short: This is more about style and readablility than about a real requirement? Just so that every future developer immediately knows, what I am doing? Like: "Oh, PUT, so that's an update" while we could still use POST instead if we wanted to??

Snapey's avatar

@Ronaldo100 you can just use post all the time if you want. Its more a matter of following the standards. See the article i linked before

Please or to participate in this conversation.