Question

I get the following error from Laravel 4.1.

ReflectionException Class Acme\Services\TaskCreatorService does not exist.

Thanks in advance for any help.

Below is the code defining the class. It is found in app\Acme\Services.


<?php namespace Acme\Services;

use \Acme\Validators\TaskValidator;
use \Acme\Validators\ValidationException;
use \Acme\Validators\Validator;

class TaskCreatorService {

    protected $validator;

    public function __construct(TaskValidator $validator) {

        $this->validator = $validator;

    }

    public function make(array $attributes) {

        //determone whether data is valid
        if ($this->validator->isValid($attributes)) {
        Task::create([
            'title' => $attributes['title'],
            'body' => $attributes['body'],
            'user_id' => $attributes['assign']
         ]);

        return true;
        }

        throw new ValidationException('Task validation failed', $this->validator-getErrors());
        //create the new task
        //
        //if not throw exception
    }
}

I have also add this to composer.json in the autoload section.

    "psr-0": {
        "Acme": "app/"
    }
Was it helpful?

Solution 2

Having your PSR-0 namespace

"Acme": "app/"

Your class file must be:

/var/www/appdir/app/Acme/Services/TaskCreatorService.php

And you have to

composer dump-autoload

Once, when you created the PSR-0 namespace. Check the file

/var/www/appdir/vendor/composer/autoload_psr0.php

And check if your namespace is there.

OTHER TIPS

For me, in my case, following did work!

composer dump-autoload

I found it with a little explanation in the following link

Hope it will be helpful!

Laravel is really harder for newbies to catch up with, specially for the people who don't know Symfony or Ruby-on-Rails techniques!

Good Luck guys!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top