ReflectionException: Class ClassName does not exist - Laravel

后端 未结 22 1188
无人共我
无人共我 2020-11-29 04:39

As soon, I am typing php artisan db:seed command.

I\'m getting Error Like:

[ReflectionException]
Clas

相关标签:
22条回答
  • 2020-11-29 05:06

    I've recreated class, and it worked. Copy all file content, delete file, and run php artisan make:seeder ModelTableSeeder. Because composer dump-autoload didn't worked for me.

    0 讨论(0)
  • 2020-11-29 05:07

    Perform a composer update, then composer dump-autoload.

    If the above doesn't solve the problem, change the classmap in your composer.json file such that it contains the project-relative path to your php files:

    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php",
            "database/seeds/UserTableSeeder.php" //include the file with its path here
        ]
    }, /** ... */
    

    and soon after, perform a composer dump-autoload, and it should work now like a breeze!

    Edit by @JMSamudio

    If composer dump-autoload is not found, just enable this option composer config -g -- disable-tls true.

    0 讨论(0)
  • 2020-11-29 05:07

    I am not writing as the answer for this question. But I want to help others if they faced the same bug but the answers mentioned here not works. I also tried all the solutions mentioned here. But my problem was with the namespace I used. The path was wrong.

    The namespace I used is:

    namespace App\Http\Controllers;
    

    But actually the controller reside inside a folder named 'FrontEnd'

    so the solution is change the namespace to:

    namespace App\Http\Controllers\Frontend;
    
    0 讨论(0)
  • 2020-11-29 05:07

    I had this error when trying to reach an endpoint in a custom route file, that had a namespace prepended in RouteServiceProvider

    • The namespace in the class was correct.
    • The file path of the class file was correct.
    • The controller call from the routes file was correct (when not taking the prepended namespace from the RouteServiceProvider into account)
    • The default $router->group(['namespace' ...]) in the RouteServiceProvider was incorrect.

    Updating the namespace in the RouteServiceProvider solved the issue, as the relative controller path specified in the routes file was now resolving correctly.

    0 讨论(0)
提交回复
热议问题