Laravel 4种子类Sentry未被发现

时间:2013-05-29 16:24:09

标签: laravel laravel-4 composer-php

我在使用php artisan db:seed时正在关注Code Forest的教程,我收到此错误:

PHP致命错误:第13行的/var/www/app/database/seeds/SentrySeeder.php中找不到“Sentry”类

这里是SentrySeeder.php:

<?php

use App\Models\User;

class SentrySeeder extends Seeder {

public function run()
{
    DB::table('users')->delete();
    DB::table('groups')->delete();
    DB::table('users_groups')->delete();

    Sentry::getUserProvider()->create(array(
        'email'       => 'admin@admin.com',
        'password'    => "admin",
        'first_name'  => 'John',
        'last_name'   => 'McClane',
        'activated'   => 1,
    ));

    Sentry::getGroupProvider()->create(array(
        'name'        => 'Admin',
        'permissions' => array('admin' => 1),
    ));

    // Assign user permissions
    $adminUser  = Sentry::getUserProvider()->findByLogin('admin@admin.com');
    $adminGroup = Sentry::getGroupProvider()->findByName('Admin');
    $adminUser->addGroup($adminGroup);
    }

}

这是User model

Sentry已添加到提供商下的应用中 我错过了什么?

3 个答案:

答案 0 :(得分:9)

您是否添加了Facade for Sentry?

添加

'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry',

到config / app.php中的外观数组

答案 1 :(得分:1)

将'Cartalyst \ Sentry \ SentryServiceProvider'添加到app / config / app.php中的服务提供商列表

答案 2 :(得分:0)

我必须在app / config / app.php文件中添加:

1

  

'Sentry'=&gt; 'Cartalyst \哨兵\外墙\ Laravel \哨兵',

到:'aliases'=&gt;阵列(

2

  

Cartalyst \哨兵\ SentryServiceProvider,

到:'providers'=&gt;阵列(