0

use Illuminate\Support\Facades\Route;


Route::get('/', 'StudentsController@index')->name('home');
Route::get('register', 'StudentsController@create')->name('create');
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class StudentsController extends Controller
{
  public function index()
  {
    return view('layout/main');
  }
    public function create()
    {
      return view('register');
    }
}

Hello, I've been having issues with routing, each time I go to /register I get a 404 and I can't find the problem in the code.
The default route works and I tried moving the route to the top.
The route exists in php artisan route:list.
When I try to return view('register') without the controller it seems to work but I need it to work with it. **Edit I am trying to load my register.blade.php file which is located in the views folder and seems to work fine when I am not using the controller, the routing is in the web.php file.

Clearing the cache doesn't seem to work either.

Yeru
  • 1
  • 1
  • Is StudentsController in Controllers dir? – Divyank Jun 13 '20 at 15:19
  • please add where and how you are trying to use the route in your question. – zahid hasan emon Jun 13 '20 at 15:19
  • The StudentsController is in the Controllers dir, and it works with '/' directory. – Yeru Jun 13 '20 at 15:26
  • I am using the route in the web.php file in the laravel framework, I am simply trying to load my register.blade.php file using the controller when someone goes to '/register' directory. – Yeru Jun 13 '20 at 15:28
  • Try `php artisan cache:clear` then `composer du` – Mahdi Zarei Jun 13 '20 at 15:30
  • I tried, It still doesn't seem to work. – Yeru Jun 13 '20 at 15:31
  • I'd like to suggest a better way for these kinds of problems by installing Xdebug and trying to trace the application line by line from bootstrap to find out the problem much easier. – Mahdi Zarei Jun 13 '20 at 15:36
  • sounds like rewrite isn't enabled on the web server – lagbox Jun 13 '20 at 15:50
  • Thank you vivek_23! It worked after I added index.php/register . lagbox the rewrite option was enabled but playing with it didn't seem to remove the index.php requirement . – Yeru Jun 13 '20 at 16:04
  • How can I fix this? Everything seems OK and the routing works fine with a different project. – Yeru Jun 13 '20 at 16:07

0 Answers0