[英]ReflectionException Class does not exist psr-4
I'm fairly new to laravel and have encountered a problem with the psr-4 autoloading in my application. 我是laravel的新手,在我的应用程序中遇到了psr-4自动加载的问题。
My folder structure: 我的文件夹结构:
-app
-config
-controllers
-UsersController
-Mynamespace
-User.php
My composer.json file: 我的composer.json文件:
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"psr-4": {
"Mynamespace\\": "app/Mynamespace"
}
Then I ran: 然后我跑了:
composer dump-autoload
My User model: 我的用户模型:
<?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 {
...
My vendor/composer/autoload-psr4.php: 我的供应商/composer/autoload-psr4.php:
...
return array(
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'Mynamespace\\' => array($baseDir . '/app/Mynamespace'),
);
Changed my config/auth.php to: 将我的config / auth.php更改为:
'model' => 'Mynamespace\User',
I keep getting a ReflectionException Class User does not exist error. 我不断收到ReflectionException类用户不存在错误。 Please help!
请帮忙!
You reflection exception 你反思异常
Class User does not exist error
类用户不存在错误
is complaining about not being able to find a class named User
. 在抱怨找不到名为
User
的类。 I don't see a class named User
defined anywhere in the above code. 在以上代码中的任何地方都没有看到名为
User
的类。 I see a class named Mynamespace\\User
, but I don't see a global class named user. 我看到一个名为
Mynamespace\\User
的类,但没有看到一个名为user的全局类。
Knowing the context that you're seeing this exception in would help, but my guess is something told Laravel to instantiate a global User
object (dependency injected type hints? Instantiating an object through app()->make
? Directly Instantiating an object?). 知道您在其中看到此异常的上下文会有所帮助,但是我的猜测是告诉Laravel实例化全局
User
对象(依赖项注入类型提示?通过app()->make
实例化对象?直接实例化对象?) 。 Without that context it's not likely anyone will be able to track this down for you. 没有这种背景,任何人都不可能为您找到答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.