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

NoLAstNamE's avatar

PUT method when do we use it?

Hey everyone!

I want to be enlightened on when we use the PUT method, I'm a little bit confused because POST and PUT for me are the same when updating a record.

Here's an example of a form, I use PUT here but removing the @method('PUT') and updating my route to post will work the same.

<form action="{{ route('post.update', $someId) }}" method="post">
    @method('PUT')
    @csrf
    
    <input type="text" name="name" value="{{ $someDefaultValueHere }}">
</form>
1 like
9 replies
undeportedmexican's avatar

It's about common practices. A way of 'knowing' what the route is for.

While you can do anything you want (you could even udpate a record using a GET request), it's common practice (And there's probably someone who has more insight than I have) that a PUT request is used for updating the record, while a POST request is used to create a new record.

So while you can use them interchangeably in a functional perspective, it's not a good practice, as other developers may try to use PUT requests to update a record and it would not allow it.

Again, this is just the common practice, and I'm pretty sure someone can explain the actual rules about it more detailed than me. But that will at least get you going.

2 likes
jlrdw's avatar

Put and delete are for rest API'S. Read the symfony documentation on these methods and look up the request methods in GitHub.

In regular database crud post is all that's needed. In fact symfony turns the put into a post if you use it anyway.

1 like
NoLAstNamE's avatar

@jlrdw and another question...

GET Retrieve the resource from the server (e.g. when visiting a page);

POST Create a resource on the server (e.g. when submitting a form);

PUT/PATCH Update the resource on the server (used by APIs);

DELETE Delete the resource from the server (used by APIs).

PUT/PATCH and DELETE are used by APIs, but in our Laravel app even if we're just making CRUDs, we use the @method('DELETE').

Please or to participate in this conversation.