【问题标题】:ReflectionException - Class name does not exist in Laravel 5.0ReflectionException - Laravel 5.0 中不存在类名
【发布时间】:2015-08-04 13:25:51
【问题描述】:

我在尝试为我的 cmets 表播种时遇到了一点问题。 我 100% 确定我的/database/seeds 目录中拥有 Class 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.'
        ));
    }

}

然后当我运行时:php artisan db:seed

我一直在得到

我也尝试运行 composer update 并运行:php artisan db:seed - 仍然得到相同的结果。

任何提示/帮助将不胜感激!

【问题讨论】:

  • 在尝试此操作之前您是否运行过composer dump-autoload
  • 还没有,好的。我现在就做。
  • 现在工作。非常感谢您的帮助。 :)
  • 没问题,将其添加为完成的答案。
  • 当然。大胆试试吧。我一定会接受的。

标签: php laravel laravel-5 seeding


【解决方案1】:

你需要运行

composer dump-autoload

修复此错误。除其他外,它的作用是刷新应用程序可用的类列表。

在这种情况下,虽然该类确实存在于正确的位置,但它在您的自动加载的类列表中不可用,因此返回 Not Found 错误。

【讨论】:

    猜你喜欢
    • 2015-12-05
    • 2014-01-24
    • 2022-10-25
    • 1970-01-01
    • 2012-04-20
    • 2017-04-03
    • 2019-11-14
    • 2021-05-31
    • 2020-03-17
    相关资源
    最近更新 更多