symfonydoctrine-ormentityclassnotfound

"Fatal error: Class not Found" in Symfony2


This is NewEventController.php:

namespace Passtuff\RestBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Passtuff\RestBundle\Entity\Event;

class NewEventController extends Controller
{   
    public function createAction()
    {
        $event = new Event(); //line 14

        //...
    }

}

and this is Event.php

namespace Passtuff\RestBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="event")
 */
class Event {
    //...    
}

I get this error:

Fatal error: Class 'Passtuff\RestBundle\Entity\Event' not found in /home/mattia/sites/Symfony/src/Passtuff/RestBundle/Controller/NewEventController.php on line 14

Why?


Solution

  • The problem was that the Entity directory had wrong permissions.

    Setting those permissions to 775 solved the problem.