2
我是laravel的新手,在我的應用程序中遇到了psr-4自動加載的問題。ReflectionException類不存在psr-4
我的文件夾結構:
-app
-config
-controllers
-UsersController
-Mynamespace
-User.php
我composer.json文件:
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"psr-4": {
"Mynamespace\\": "app/Mynamespace"
}
然後我跑:
composer dump-autoload
我的用戶模型:
<?php namespace Mynamespace;
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
use Eloquent;
class User extends Eloquent implements UserInterface, RemindableInterface {
...
我的供應商/作曲/自動加載-psr4.php:
...
return array(
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'Mynamespace\\' => array($baseDir . '/app/Mynamespace'),
);
改變了我的config/auth.php到:
'model' => 'Mynamespace\User',
我不斷收到一個ReflectionException類用戶不存在錯誤。請幫忙!
您是否已將['app/config/auth.php'](https://github.com/laravel/laravel/blob/master/app/config/auth.php#L31)中的'model'更改爲' myNameSpace對象\ User'? – Marwelln 2014-11-14 21:53:39
是的\t'model'=>'Mynamespace/User', – WaffleBoy 2014-11-14 22:06:00
您的用戶模型存儲在名爲'User.php'的文件中,對嗎?我問,因爲你稱它爲你的UsersController。 – wolfemm 2014-11-14 23:00:50