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

Farirai's avatar

Route [home] not defined.

my route web.php

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PS\HomeController;
use App\Http\Controllers\PS\EmployeeController;
use App\Http\Controllers\PS\CompanyController;
use App\Http\Controllers\PS\ProjectController;
use App\Http\Controllers\PS\StageController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::middleware(['auth', 'verified'])->group(function () {

    Route::get('home', [HomeController::class, 'index']);

    Route::resource('/employees', EmployeeController::class);
    Route::resource('/companies', CompanyController::class);
    Route::resource('/projects', ProjectController::class);
    Route::resource('/stages', StageController::class);
});


my controller

<?php

namespace App\Http\Controllers\PS;

use App\Http\Controllers\Controller;
use App\Models\Project;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class HomeController extends Controller
{
    /**
     * Display a listing of the resource.
     */

    public function index()
    {
        $projects = Project::all();

        $pendingCount = DB::table('projects')
            ->where('status', 'pending')
            ->count();

        return view('home.index', [
            'projects' => $projects,
            'pendingCount' => $pendingCount,
        ]);
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     */
    public function show(string $id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit(string $id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, string $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(string $id)
    {
        //
    }
}

0 likes
4 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

The error "Route [home] not defined" means that Laravel is unable to find a named route with the name "home". In this case, the named route is defined in the web.php file as follows:

Route::get('home', [HomeController::class, 'index'])->name('home');

To fix the error, you need to make sure that you are using the correct name for the route in your views or other parts of your application. For example, if you want to generate a link to the "home" route, you can use the following code:

<a href="{{ route('home') }}">Home</a>

Make sure that you are using the correct name for the route and that it matches the name defined in the web.php file.

stainzxc's avatar

@LaryAI Hello sir, I have the same error but i dont have the home route in my web. Why i got this error?

Route::get('/', function () { return view('auth.index'); })->middleware(['verify.shopify'])->name('index');

Route::view('/index', 'auth.index') ->middleware(['verify.shopify']) ->name('index');

Route::view('/login', 'auth.login') ->middleware(['verify.shopify']) ->name('login');

Route::view('/register', 'auth.register') ->middleware(['verify.shopify']) ->name('register');

Route::view('/product', 'dashboard.product') ->middleware(['verify.shopify']) ->name('product');

Route::view('/transaction', 'dashboard.transaction') ->middleware(['verify.shopify']) ->name('transaction');

Route::view('/cart', 'transactions.cart') ->middleware(['verify.shopify']) ->name('cart');

Route::view('/shipping', 'transactions.shipping') ->middleware(['verify.shopify']) ->name('shipping');

Route::view('/payment', 'transactions.payment') ->middleware(['verify.shopify']) ->name('payment');

Route::view('/order', 'transactions.order') ->middleware(['verify.shopify']) ->name('order');

JussiMannisto's avatar

@stainzxc Your app is trying to use a route named 'home', but it doesn't exist in your route definitions.

Please or to participate in this conversation.