The problem was that the Entity directory had wrong permissions.
Setting those permissions to 775
solved the problem.
Question
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.
OTHER TIPS
try clearing your cache in app/cache and make sure you have added your bundle to kernel.
You need to make sure you have the PasstuffRestBundle
registered in the AppKernel.php
file, inside your application directory:
class AppKernel extends Kernel
{
// ...
public function registerBundles()
{
$bundles = [
new Passtuff\RestBundle\PasstuffRestBundle(),
];
}
}
Then you need to make sure your bundle is in the right directory and follows the right conventions, in this case, PSR-0 conventions:
app/
src/
Passtuff/
RestBundle/
PasstuffRestBundle.php
web/
For more information, check out the official docs on best practices for structuring bundles.