1
votes

I have the following error when i view my site.

My Error:

Fatal error: Uncaught ReflectionException: Class log does not exist in /home/vagrant/Code/in10km/vendor/laravel/framework/src/Illuminate/Container/Container.php:741> Stack trace: #0 /home/vagrant/Code/in10km/vendor/laravel/framework/src/Illuminate/Container/Container.php(741): ReflectionClass->__construct('log') #1 /home/vagrant/Code/in10km/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('log', Array) #2 /home/vagrant/Code/in10km/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('log', Array) #3 /home/vagrant/Code/in10km/vendor/laravel/framework/src/Illuminate/Container/Container.php(842): Illuminate\Foundation\Application->make('log') #4 /home/vagrant/Code/in10km/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter)) > #5 /home/vagrant/Code/in10km/vendor/laravel/framework/src/Illuminate/Container/Container.php(774): Il in /home/vagrant/Code/in10km/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 741

My Composer.json file is like this

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "doctrine/dbal": "v2.4.2",
        "swiftmailer/swiftmailer": "^5.4",
        "guzzlehttp/guzzle": "~5.3|~6.0",       
        "chrisbjr/api-guard": "^2.3",
        "serverfireteam/panel": "1.3.*",
        "laravel/socialite": "^2.0"

    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "files": [
            "app/Http/helpers.php",
            "app/Support/helpers.php"
        ],
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

Anyone help me how to get rid of this error and view my site successfully.

5

5 Answers

3
votes

Delete all files in bootstrap/cache/ then run:

composer dump-autoload -o

1
votes

I found the solution, in my routes i don't called exactly the name of the Controller

Example:

Route::get('/endpoint', 'Namebadcontroller@function');

// Correct name of route
Route::get('/endpoint', 'NameBadController@function');

And run the follow commands:

composer dump-autoload -o

php artisan clear-compiled php artisan optimize

0
votes

I had a similar issue. I found that to really dig down into the issue, you need to modify the Illuminate/Container/Container.php file, as suggested here at the third from the top.

<?php

namespace {
    use Monolog\Logger as Monolog;
    class log extends Illuminate\Log\Writer {
        function __construct()
        {
            $this->monolog = new Monolog("local");
        }
    }
}

namespace Illuminate\Container {

    use Closure;
    use ArrayAccess;
    use ReflectionClass;
    use ReflectionMethod;
    use ReflectionFunction;
    use ReflectionParameter;
    use InvalidArgumentException;
    use Illuminate\Contracts\Container\Container as ContainerContract;
    use Illuminate\Contracts\Container\BindingResolutionException as BindingResolutionContractException;


    class Container implements ArrayAccess, ContainerContract
    {

Modify it as the code suggests, and add an additional closing bracket to the bottom. This will allow it to display the error that it otherwise has been unable to display and thus be able to fix your problem!

0
votes

Delete vendor file and then run composer update

-2
votes

Try the command composer dump-autoload -o.

I used it to overcome the problem: 'Uncaught ReflectionException'.

Good luck!