我安装并配置了 - https://github.com/Propaganistas/Laravel-FakeId
编写以下内容 -
routes.php文件
Route::model('orange', 'App\Orange'); Route::resource('orange', 'OrangeController');
Orange.php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Propaganistas\LaravalFakeId\FakeIdTrait;
class Orange extends Model
{
use FakeIdTrait;
protected $fillable = ['orange_name'];
}
当我加载http://localhost:8000/orange/3
时我收到了以下内容 -
FatalErrorException in Orange.php line 10: Trait 'Propaganistas\LaravalFakeId\FakeIdTrait' not foun
d
我认为之前我没有在供应商包中使用过特征 - 通常我在App文件夹中定义。是否有某种配置等我需要设置才能使其正常工作?
我的作曲家json是 -
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"propaganistas/laravel-fakeid": "^1.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}