【发布时间】:2013-12-09 20:57:38
【问题描述】:
我必须将命名空间合并到我的项目中,因为我需要使用一个名为“事件”的模型,从而避免 Laravel 使用的预定义“事件”出现错误。
作曲家.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 {
指向模型的目录结构:
models/app/User.php
尝试“登录”时出错(这在需要命名空间之前有效):
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class '\User' not found
登录功能:
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”。
对于为什么这不再起作用的任何帮助,我们将不胜感激。
【问题讨论】:
标签: namespaces laravel-4