在Laravel中设置我自己的库时出现ReflectionException错误

时间:2014-03-10 15:48:48

标签: php laravel laravel-4

我是Laravel的新手。我正在按照教程,其中有人设置自定义库来验证表单。我的目录结构设置如下:

Lara
----->app----->Acme----->Services
                   ----->Validators
----->bootstrap
----->public
----->vendor

我收到错误:ReflectionException Class Acme\Services\TasksValidator does not exist

我怀疑它在我的TaskController中,它是这样开始的:

<?php
use \Acme\Services\TaskCreatorService;

class TasksController extends BaseController{
        protected $taskCreator;

        public function __construct(TaskCreatorService $taskCreator){
            $this->taskCreator = $taskCreator;

        }

        public function index(){
        $tasks = Task::with('user')->get();
        $users = User::lists('username', 'id');

我做错了什么?我在autoload

下的composer.json中添加了以下内容
        "psr-0":{
            "Acme":"app/"
        }

我也跑:composer dump-autoload -o

我的TaskCreatorService文件开头如下:

<?php
namespace Acme\Services;

use Acme\Validators\TaskValidator;
use Acme\Validators\ValidationException;
use Task;

class TaskCreatorService{
    protected $validator;

1 个答案:

答案 0 :(得分:1)

您需要

use Acme\Validators\TaskValidator;

在课堂上使用:

\Acme\Services\TasksValidator (with an S)