MartinZeltin
8 months ago
101
6
Laravel

How to call [email protected] from a route without a controller?

Posted 8 months ago by MartinZeltin

I know that I can call a controller function like [email protected] but what if I don't want a controller but just a simple plain class with a method and to call that method, is that possible?

For example:

<?php 
    namespace App;

    class MyNewClass
    {
        public function doSomething()
        {
            echo "Hello world!";
        }
    }
?>

and call it like this from my routes

    Route::get('endpoint', '[email protected]');

Please sign in or create an account to participate in this conversation.