Stuart Little Stuart Little - 8 months ago 43
PHP Question

Cant find class when using "Whoops!" library?

Recently I have been trying the Whoops! library and trying to get it to work, however, unfortunately this is the closest I have gotten to get it working.

I installed it via the composer using this tutorial


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

# index.php
require(getcwd() . "/vendor/autoload.php");

$whoops = new Whoops\Run();
$whoops->pushHandler(new Whoops\Handler\PrettyPageHandler());

// Set Whoops as the default error and exception handler used by PHP:

throw new RuntimeException("Oopsie!");


Fatal error: Uncaught Error: Class 'Whoops\Run' not found in C:\Users\Administrator\Desktop\CMS\app\library\whoops\index.php:9 Stack trace: #0 {main} thrown in C:\Users\Administrator\Desktop\CMS\app\library\whoops\index.php on line 9

Answer Source

I just ran your code and it ran fine for me (it actually did nothing, but the class loaded just fine). Check your composer.json and ensure it has:

    "name": "root/stack-overflow",
    "minimum-stability": "stable",
    "require": {
        "filp/whoops": "1.*"

Run composer update just to be sure. And lastly ensure that your index.php is in the directory that has vendor as a subdirectory.