bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

POST,PUT,DELETE requests method keeps returning 405 method not found #1249

Closed peterson-umoke closed 2 years ago

peterson-umoke commented 2 years ago

I have been screaming at my computer for hours now. Everything seems to be done right, but i can't get any other method apart from GET requests to work.

peterson-umoke commented 2 years ago

Its keeps returning this error `<!DOCTYPE html>

405 Method Not Allowed

Method Not Allowed

HTTP 405 (GET /contactz)

[vendor/bcosca/fatfree-core/base.php:1835] Base->error()
[index.php:16] Base->run()
`
pauljherring commented 2 years ago

You need to add the verb to your route. If none is specified, then it defaults to just allowing GET.

$f3->route('GET|HEAD|POST|DELETE @sessions: /sessions', 'PJH\Page->sessions');

Or use map() if you're doing REST: https://fatfreeframework.com/3.7/routing-engine#ReST:RepresentationalStateTransfer

On Fri, 11 Mar 2022, 12:20 Peterson Umoke, @.***> wrote:

Its keeps returning this error `

405 Method Not Allowed Method Not Allowed HTTP 405 (GET /contactz) [vendor/bcosca/fatfree-core/base.php:1835] Base->error() [index.php:16] Base->run() ` — Reply to this email directly, view it on GitHub , or unsubscribe . Triage notifications on the go with GitHub Mobile for iOS or Android . You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
pauljherring commented 2 years ago

Incidentally, this sort of question is better suited to the group, rather than raising an issue:

https://groups.google.com/g/f3-framework