Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Namespaces 添加命名空间后出现错误。无法访问模型_Namespaces_Laravel 4 - Fatal编程技术网

Namespaces 添加命名空间后出现错误。无法访问模型

Namespaces 添加命名空间后出现错误。无法访问模型,namespaces,laravel-4,Namespaces,Laravel 4,我必须将名称空间合并到我的项目中,因为我需要使用一个名为“Event”的模型,从而避免Laravel使用的预定义“Event”出现错误 Composer.json: "autoload": { "classmap": [ "app/commands", "app/controllers", "app/models", "app/database/migrations", "app/database/s

我必须将名称空间合并到我的项目中,因为我需要使用一个名为“Event”的模型,从而避免Laravel使用的预定义“Event”出现错误

Composer.json:

    "autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
    ]
},

"psr-0": {
    "App": "app/models/"
    },
用户模型:

<?php

namespace App;
use Eloquent;

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {
登录功能:

public function postSignin(){
    if (Auth::attempt(array('email'=>Input::get('email'), 'password'=>Input::get('password')))) {

    $title   = Auth::user()->title;
    $surname = Auth::user()->surname;
在编辑composer.json文件后,我运行了命令“composer dump autload”


非常感谢您提供的任何帮助,以解释为什么这不再有效。

如果您遵循的是
psr-0
,那么您的模型目录结构应该是:

app/
    models/
        App/
            User.php
然后尝试在config中设置模型,转到:
app/config/auth.php

改变模式

'model'=>'\App\User'


祝你好运

即使psr-4记住在config/auth中设置模型也是有帮助的。谢谢
app/
    models/
        App/
            User.php