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

Logic's avatar
Level 1

Exception Class request does not exists in index.php

i have uploaded my laravel project to live server but its not working when i track code i get the execption that class request does not exists,please help me to find out the error this is my file index.php

<?php
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$app->bind('path.public', function() {

    return __DIR__;

});

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

try{
$request = App\Http\Request::capture()
}
catch(Exception $e)
{
    echo "error:".$e->getMessage()."<br>";
}

$response = $kernel->handle(
    $request = App\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);
0 likes
11 replies
tykus's avatar

What are you trying to do exactly? Why do you need to catch an exception at this point?

ChristophHarms's avatar

you are trying to require public/bootstrap/autoload.php and public/bootstrap/app.php, which normally don't exist if you didn't put them there. If the directory structure of your app is similar to the default directory structure, change the first three lines to

<?php
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';+
Logic's avatar
Level 1

@tykus because my website is showing 500:internal server error unable to handle request,there for i have check the index.php and i come up with the exception 'class request does not exist'

tykus's avatar

Has the original 500 error actually directed you to the index.php file?

I would suspect that you have forgotten to alias (use App\Http\Request) the Request class in a controller/other class; but, the detail of this will be in the Exception.

Logic's avatar
Level 1

previously it was like this

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

but if i put this code my sites shows this message "conferenceearth.com is currently unable to handle this request. HTTP ERROR 500 "

tykus's avatar

What does the actual exception say?

Logic's avatar
Level 1

by default my site is showing the error i have reported in last reply,and when i track the index.php the line $request = Illuminate\Http\Request::capture() is throwing an exception that 'class request does not exists' it would be great if you can specify which file and line has to be modified

tykus's avatar

That's the friendly message displayed in the browser - what is in your server's logs / Laravel logs?

It could be any number of things causing this; e.g. unsupported PHP version, failure to run composer install on your server, permissions, missing environment variables.

2 likes
Logic's avatar
Level 1

this is my exception details

            object(ReflectionException)#23 (7) {
              ["message":protected]=>
              string(28) "Class request does not exist"
              ["string":"Exception":private]=>
              string(0) ""
              ["code":protected]=>
              int(-1)
              ["file":protected]=>
              string(97) "/home/conferenceearth/public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php"
              ["line":protected]=>
              int(734)
              ["trace":"Exception":private]=>
              array(6) {
                [0]=>
                array(6) {
                  ["file"]=>
                  string(97) "/home/conferenceearth/public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php"
                  ["line"]=>
                  int(734)
                  ["function"]=>
                  string(11) "__construct"
                  ["class"]=>
                  string(15) "ReflectionClass"
                  ["type"]=>
                  string(2) "->"
                  ["args"]=>
                  array(1) {
                    [0]=>
                    string(7) "request"
                  }
                }
                [1]=>
                array(6) {
                  ["file"]=>
                  string(97) "/home/conferenceearth/public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php"
                  ["line"]=>
                  int(629)
                  ["function"]=>
                  string(5) "build"
                  ["class"]=>
                  string(30) "Illuminate\Container\Container"
                  ["type"]=>
                  string(2) "->"
                  ["args"]=>
                  array(2) {
                    [0]=>
                    string(7) "request"
                    [1]=>
                    array(0) {
                    }
                  }
                }
                [2]=>
                array(6) {
                  ["file"]=>
                  string(100) "/home/conferenceearth/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php"
                  ["line"]=>
                  int(697)
                  ["function"]=>
                  string(4) "make"
                  ["class"]=>
                  string(30) "Illuminate\Container\Container"
                  ["type"]=>
                  string(2) "->"
                  ["args"]=>
                  array(2) {
                    [0]=>
                    string(7) "request"
                    [1]=>
                    array(0) {
                    }
                  }
                }
                [3]=>
                array(6) {
                  ["file"]=>
                  string(96) "/home/conferenceearth/public_html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php"
                  ["line"]=>
                  int(105)
                  ["function"]=>
                  string(4) "make"
                  ["class"]=>
                  string(33) "Illuminate\Foundation\Application"
                  ["type"]=>
                  string(2) "->"
                  ["args"]=>
                  array(2) {
                    [0]=>
                    string(7) "request"
                    [1]=>
                    array(0) {
                    }
                  }
                }
                [4]=>
                array(4) {
                  ["file"]=>
                  string(96) "/home/conferenceearth/public_html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php"
                  ["line"]=>
                  int(564)
                  ["function"]=>
                  string(3) "app"
                  ["args"]=>
                  array(1) {
                    [0]=>
                    string(7) "request"
                  }
                }
                [5]=>
                array(4) {
                  ["file"]=>
                  string(43) "/home/conferenceearth/public_html/index.php"
                  ["line"]=>
                  int(56)
                  ["function"]=>
                  string(7) "request"
                  ["args"]=>
                  array(0) {
                  }
                }
              }
              ["previous":"Exception":private]=>
              NULL
            }
tykus's avatar
tykus
Best Answer
Level 104

Also, is this the literal message: class request does not exist i.e. lowercase request - you probably have been working on a case-insensitive development machine and uploaded to a case-sensitive server - I would hunt that down if it was not a typo earlier!

tykus's avatar

Also, your .env is exposed!!!! Sort that out immediately!

2 likes

Please or to participate in this conversation.