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

osherdo's avatar

Cannot run a page in Laravel

trying to run a page and i get the following error:

NotFoundHttpException in RouteCollection.php line 143:

I am trying to run the view 'RunChat'.

routes.php:

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

Route::get('RunChat','ChatController@RunIt');


public function RunIt ()
{ 
    $UserDetails=[
    'UserId'=>"osherdo@gmail.com",
    'Password'=>'1234'];


return view('RunChat',compact(UserDetails));
}

ChatController.php:

<?php namespace App\Http\Controllers;

class WelcomeController extends Controller {
public function __construct()
    {
        $this->middleware('guest');
    }
public function RunIt ()
{ 
    $UserDetails=[
    'UserId'=>"osherdo@gmail.com",
    'Password'=>'1234'];


return view('RunChat',compact(UserDetails));
}

RunChat.blade.php:

<html>
<body>


    <p><b> Hello. This is a chat page.</b></p>

<b> you're {{$UserDetails['UserId']}} </b>

</body>
</html>

what's wrong? tried to google it back and forth and could not sort it out.

Thanks in advance.

0 likes
3 replies
martink8's avatar

Hmm. I am not exactly sure what are you trying to accomplish.

First your ChatController.php is set as class WelcomeController. The class name has to be the same name as the filename.

You also usually don't uppercase function and variable names.

Why do you have the RunIt function in the routes.php?

Edit: Also you have another error. The compact function takes in a string. So it has to be like this: return view('RunChat',compact('UserDetails'));

osherdo's avatar

@martink8 thank you for your reply. I am trying to run the view called runchat.blade

i have takedn your comments into account and fixed my code according to them.

Now I am getting another error:

Undefined variable: userdetails (View: C:\Users\Osher\Desktop\laravel\SportsApp\resources\views\runchat.blade.php)

Trying to figure out now what to do. will update you if i am manged to succeed.

meanwhile here's my updated code:

routes.php:

<?php

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

chatcontroller.php:

<?php namespace App\Http\Controllers;

class chatcontroller extends Controller {

Route::get('runchat','ChatController@runit');

public function __construct()
    {
        $this->middleware('guest');
    }

public function runit ()
{ 
    $userdetails=[
    'userid'=>"osherdo@gmail.com",
    'password'=>'1234'];


return view('RunChat',compact('UserDetails'));
}
}

runchat.blade.php:

<html>
<body>


    <p><b> Hello. This is a chat page.</b></p>

<b> you're {{$userdetails['userid']}} </b>

</body>
</html>
billmurrin's avatar

Routes.php

Route::get('RunChat','ChatController@runit');

ChatController.php

<?php namespace App\Http\Controllers;

class ChatController extends Controller {

    public function __construct()
     {
            $this->middleware('guest');
        }

    public function runit ()
    { 
            $userdetails=[
            'userid'=>"osherdo@gmail.com",
        'password'=>'1234'];
        
        return view('runchat',compact('userdetails'));
    }
}

runchat.blade.php

    <p><b>Hello. This is a chat page.</b></p>

<b> you're { { $userid } } </b>

Please or to participate in this conversation.