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

StarShines's avatar

Is Route without URL possible in laravel 9?

Hi All!

Is it possible to write method in form action to access controller method directly without using routes or without writing the url in routes.

Apologies if it sounds strange but at times, one may need to access controller methods directly.

Your descriptive thoughts are highly appreciated.

Thank you

0 likes
7 replies
jlrdw's avatar

No in laravel you need routing. I also wish some methods could be used without.

kokoshneta's avatar

No, there is no way to do that. You cannot access PHP from a form.

A form is an HTML element rendered on a page in a browser on the user’s machine. It doesn’t live on your server, but with the user.

The only way a form (or anything else on the user’s machine) has to communicate with your server is to send a request, generally an HTTP request. A request needs an endpoint, which is a URL. You cannot directly access some random piece of code on your server from the user’s browser. In Laravel, the way to specify a URL for a form to call is by using routes.

bestmomo's avatar

I wonder from where you want to access controller methods.

martinbean's avatar
Level 80

Is it possible to write method in form action to access controller method directly without using routes or without writing the url in routes.

@shunmas No.

one may need to access controller methods directly.

No, you don’t.

Routes map URI patterns to controllers. There’s no such things as “accessing controller methods directly”.

1 like
patrickkellar's avatar

I agree with @martinbean

If you think you need to access a method in a controller directly you should think about abstracting them to a Service class (or something similar) and then defer your controller to use that service class instead.

1 like
MerryChristmas's avatar

Create separate class file. Move the logic inside.

And then call that class from controller and any other location.

Please or to participate in this conversation.