简体   繁体   English

ReflectionException-Laravel 5.0中不存在类名

[英]ReflectionException - Class name does not exist in Laravel 5.0

I have a little problem trying to seed my comments table. 尝试为我的评论表添加种子时,我遇到了一个小问题。 I'm 100% sure that I have the Class CommentTableSeeder.php in my /database/seeds directory. 我100%确定我的/database/seeds目录中具有 Class CommentTableSeeder.php


CommentTableSeeder.php CommentTableSeeder.php

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class CommentTableSeeder extends Seeder {

    public function run()
    {
        DB::table('comments')->delete();

        Comment::create(array(
            'author' => 'Chris Sevilleja',
            'text' => 'Look I am a test comment.'
        ));

        Comment::create(array(
            'author' => 'Nick Cerminara',
            'text' => 'This is going to be super crazy.'
        ));

        Comment::create(array(
            'author' => 'Holly Lloyd',
            'text' => 'I am a master of Laravel and Angular.'
        ));
    }

}

Then when I run : php artisan db:seed 然后当我运行时: php artisan db:seed

I kept getting 我不断

在此处输入图片说明

I've also try running composer update and run : php artisan db:seed - still get the same result. 我也尝试运行composer update并运行: php artisan db:seed仍然得到相同的结果。

Any hints / help will be much appreciated ! 任何提示/帮助将不胜感激!

You need to run 你需要跑步

composer dump-autoload

to fix this error. 解决此错误。 What this does, among other things, is refreshes the list of classes available to your application. 除其他功能外,此操作还刷新了可用于您的应用程序的类的列表。

In this case, while the class did exist in the right location, it was unavailable in your autoloaded class list, and thus returning a Not Found error. 在这种情况下,尽管该类确实存在于正确的位置,但是在您的自动加载的类列表中该类不可用,因此返回“ Not Found错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM