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

gurvindersingh's avatar

PHP Fatal error: Uncaught Error: Class 'Monolog\Handler\StreamHandler' not found

When I'm trying to run php artisan migrate I'm facing this issue

PHP Fatal error: Uncaught Error: Class 'Monolog\Handler\StreamHandler' not found laravel

As someone mentioned

In your composer.json file, please change "minimum-stability" from "dev" to "stable" I had the same issue and did the trick Then run composer dump-autoload.

But i don't have anu minimum-stability in composer.json file.

and i also run composer update --no-script but this is not works for me.

0 likes
8 replies
michapietsch's avatar

composer dump-autoload will make the existing classes available. But does the Class 'Monolog\Handler\StreamHandler' exist? You could check that in the vendor directory.

Now what is the effect of the minimum-stability property? It affects dependency resolution, that means how composer determines which package versions to install. I guess in this case it's about a difference between versions of the Monolog package. The class is expected in it but the installed version somehow does not include it.

That's my guess where I'd look for the cause of the error.

If you want to try to set minimum-stability and your composer.json does not have it, you could add it.

If it doesn't help, could you please look into composer.lock and see which version of Monolog is installed?

1 like
gurvindersingh's avatar

Thanks @michapietsch for your valuable response.

But it doesn't work for me.

As i check composer.lock file

monolog version is "monolog/monolog": "~1.12"

and class 'Monolog\Handler\StreamHandler' doesn't exists.

Ishatanjeeb's avatar

You can solve this issue by changing "minimum-stability" from "dev" to "stable" in composer.json. Then running composer update.

gurvindersingh's avatar

@Ishatanjeeb please check my coposer.json file This line "minimum-stability": "stable", i added manually after facing this issue.

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "minimum-stability": "stable", 
    "require": {
        "php": ">=7.0.0",
        "fideloper/proxy": "~3.3",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "laravel/homestead": "^7.0",
        "mockery/mockery": "~1.0",
        "phpunit/phpunit": "~6.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }
}

michapietsch's avatar

So according to your composer.lock you have version 1.12 installed. I just checked the Github repo for Monolog, chose the 1.12 tag and there the Class exists: https://github.com/Seldaek/monolog/blob/1.12.0/src/Monolog/Handler/StreamHandler.php

Can you confirm, that in the vendor directory, amongst the monolog files you can see this class?

To doubt the mere existence of this class file might seem weird, but who knows what weird things could happen? :)

Please or to participate in this conversation.