user1801060
user1801060

Reputation: 2821

ReflectionException error when setting up my own library in Laravel

I am a Laravel newbie. I'm following a tutorial where someone sets up a custom library to verify forms. My directory structure is setup like this:

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

I get an error: ReflectionException Class Acme\Services\TasksValidator does not exist

I suspect it's in my TaskController which starts like this:

<?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');

What am I doing wrong? I've added the following in my composer.json under autoload

        "psr-0":{
            "Acme":"app/"
        }

I've also run: composer dump-autoload -o

My TaskCreatorService file begins like this:

<?php
namespace Acme\Services;

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

class TaskCreatorService{
    protected $validator;

Upvotes: 0

Views: 264

Answers (1)

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87719

You are requiring

use Acme\Validators\TaskValidator;

And using in your class:

\Acme\Services\TasksValidator (with an S)

Upvotes: 1

Related Questions