1

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.

7 Answers 7

5

Delete all files in bootstrap/cache/ then run:

composer dump-autoload -o

Sign up to request clarification or add additional context in comments.

Comments

1

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!

Comments

1

Delete vendor file and then run composer update

Comments

1

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

Comments

1

The issue might originate from a package that is not (yet) downloaded in your vendor folder (with all installed vendor packages) In that case composer dump-autoload -o does not fix your issue.

Check you composer.json and composer.lock.

I added main into my branch from a GIT repo.

composer.json and composer.lock did not match!

The resolution was to recover composer.json and composer.lock from main and readded all changes from my branch manually.

Just to be sure I also removed my vendor folder.

Running composer install (re)installed all packages stored in composer.lock and added all (newer) not yet installed.

Notice that running composer update might fix the issue, but alse updates packages that perhaps may not be updated.

Comments

0

In my case the problem was a casing mismatch between class names + namespaces and the filepath. For example Services/MyService.php and namespace services, class Myservice.

When you run composer i look for does not comply with psr-4 autoloading standard. Skipping. as this indicates that you've got a problem, and this could be a casing mismatch.

It's possible that this casing mismatch isn't an issue in case insensitive filesystems like the default MacOS filesystem, or Windows, but in Linux it definitely is.

Comments

-2

Try the command composer dump-autoload -o.

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

Good luck!

1 Comment

Wow.Thanks for making it standardize.I'm a junior programmer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.