I'm using laravel 7.x.
since function(){return view(welcome);}
will produce an error when I run php artisan route:cache
, so I write this code below to replace function()
:
Route::get('/', 'WelcomeController@index')->name('welcome');
It run well on php artisan serve
command.
But when i run directly from public
folder, it produce exception MethodNotAllowedHttpException
. I couldn't find why it happened, could you help me why it happened?
exception message:
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: HEAD.
https://localhost/laravel-tester/public/
WelcomeController Method
public function index(){
return view('welcome');
}