The autoloader expected class [...] to be defined in file

There is a problem with namespaces in your files.

Remove line

namespace Arcturus\GeomancieBundle\Entity;

from DefaultController.php and TirageController.php, and put it in Tirage.php

<?php

namespace Arcturus\GeomancieBundle\Entity;

class Tirage
{

You can read more about namespaces here: http://php.net/manual/en/language.namespaces.php


For those using phpstorm

Here is a neat trick. Mark the src directory as "Sources Root", this way whenever a file is created within your src directory, it'll automatically add the correct namespace.

This will help avoid the error:

The autoloader expected class […] to be defined in file

Here is an image showing how to mark your directory as "Sources Root".

mark directory as sources root


Your namespaces are a bit out, you just put one in put class.

The controller should have the single namespace of;

namespace Arcturus\GeomancieBundle\Controller;

and your entity should have the namespace of;

namespace Arcturus\GeomancieBundle\Entity;

Also, have you set your routing up properly? If you are using annotations, something like (in app/config/routing.php);

app:
    resource: "@GeomancieBundle/Controller/"
    type: annotation

or

my_route:
    path: /my-url
    defaults:   {_controller: ArcturusGeomancieBundle:Tirage:afficherTirage }

Tags:

Symfony