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

ls-al's avatar
Level 3

REST API routes

Hello,

I am testing some API patterns for a potential project on Laravel 5.1 and the results are not clear.

I have defined the following route in routes.php

Route::any('test/api/get', function() {
return $_SERVER['REQUEST_METHOD'];

});

When I use curl with with GET verb the results are fine, when I try

curl -X PUT example.com
it says something went wrong.

How's laravel 5.1 handling the verbs of restful? I notice the html forms are using _METHOD as a hidden input to pass the verb. But I assume normal rest api requests are handled as well by laravel?

0 likes
1 reply
ls-al's avatar
ls-al
OP
Best Answer
Level 3

Needed to exclude the route from csrf protection.

1 like

Please or to participate in this conversation.