我使用的是ENTRUST (Laravel 5 Package)。当我在Php工匠的Shell命令行中使用命令User::all();
时。提示错误
PHP致命错误:在第一行eval()'d代码中找不到Class 'User'
但尝试2-3不同的组合(这是错误的)后,如果我使用相同的User::all();
,它给了我正确的结果。它看起来很奇怪。
我对PHP和Laravel都是新手。
User.php
<?php
use ZizacoEntrustTraitsEntrustUserTrait;
class User extends Eloquent
{
use EntrustUserTrait; // add this trait to your user model
}
控制台输出:
Psy Shell v0.7.2 (PHP 5.5.9 ΓÇö cli) by Justin Hileman
>>> User::all();
PHP Fatal error: Class 'User' not found in eval()'d code on line 1
>>> App/User::all();
PHP Fatal error: Class 'User' not found in eval()'d code on line 1
>>> AppUser::all();
PHP Fatal error: Class 'AppUser' not found in eval()'d code on line 1
>>> User::all();
=> IlluminateDatabaseEloquentCollection {#664
all: [
User {#665
id: 1,
name: "Kartik",
email: "******************",
password: "qwerty",
remember_token: null,
created_at: "2016-08-18 17:13:40",
updated_at: "2016-08-18 17:13:40",
},
User {#666
id: 2,
name: "Bhandari",
email: "**************",
password: "qwerty",
remember_token: null,
created_at: "2016-08-20 11:37:26",
updated_at: "2016-08-20 11:37:26",
},
],
}
给出模态的完整路径,即使用命名空间
project_namespaceModelsUser::all()