I'm new to Symfony 3. I try to resolve a problem with my two controllers. When I execute the indexAction function I've got this error :
The autoloader expected class "Arcturus\GeomancieBundle\Controller\TirageController" to be defined in file "/Applications/MAMP/htdocs/geomancie2/geomancie/vendor/composer/../../src/Arcturus/GeomancieBundle/Controller/TirageController.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
I've found that can be a typo in a class...but did'nt find anything wrong.
Here's my two controllers :
DefaultController.php
<?php
namespace Arcturus\GeomancieBundle\Controller;
namespace Arcturus\GeomancieBundle\Entity;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form;
use Symfony\Component\HttpFoundation\Request;
use Arcturus\GeomancieBundle\Entity;
class DefaultController extends Controller
{
public function indexAction(Request $request) {
$tirage = new Tirage();
$formTirage = $this->createFormBuilder($tirage)->getForm();
// Si le formulaire a été soumis
$formTirage->handleRequest($request);
if ($formTirage->isSubmitted() && $formTirage->isValid()) {
$tirage = $formTirage->all();
return $this->redirectToRoute('arcturus_geomancie_tirage', $tirage);
}
// Si le formulaire n'a pas été soumis
return $this->render('ArcturusGeomancieBundle:Default:index.html.twig', array(
'form' => $formTirage->createView(),
));
}
}
TirageController.php
<?php
namespace Arcturus\GeomancieBundle\Controller;
namespace Arcturus\GeomancieBundle\Entity;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class TirageController extends Controller
{
public function afficherTirageAction(Tirage $tirage)
{
// On compte le nombre de points dans chaque chaîne
$nb_dot_l1 = $this->nbDot($tirage->getLigne1());
$nb_dot_l2 = $this->nbDot($tirage->getLigne2());
$nb_dot_l3 = $this->nbDot($tirage->getLigne3());
$nb_dot_l4 = $this->nbDot($tirage->getLigne4());
// On vérifie que les 4 chaînes contriennent au moins 1 point
if ($nb_dot_l1 == 0 or $nb_dot_l2 == 0 or $nb_dot_l3 == 0 or $nb_dot_l4 == 0) {
// On renvoie sur une page d'erreur
$this->renderView('@ArcturusGeomancie/Default/erreur_tirage.html.twig');
}
// On charge les lignes dans un tableau paire/impaire
$tab_dots_lines = $this->dots_to_array($nb_dot_l1, $nb_dot_l2, $nb_dot_l3, $nb_dot_l4);
// On garde ce format pour dessiner la figure
$data['dessin'] = $tab_dots_lines;
// On récupère le nom de la figure
$data['figure'] = $this->get_figure($tab_dots_lines);
// On récupère l'analyse associée
$data['analyse'] = $this->get_analysis($data['figure']);
$this->renderView('@ArcturusGeomancie/Default/tirage.html.twig', $data);
}
[...]
Tirage.php (Entity)
<?php
class Tirage
{
private $ligne1;
private $ligne2;
private $ligne3;
private $ligne4;
public function getLigne1()
{
return $this->ligne1;
}
public function getLigne2()
{
return $this->ligne2;
}
public function getLigne3()
{
return $this->ligne3;
}
public function getLigne4()
{
return $this->ligne4;
}
}
?>
And my directory tree :
Could anyone help me to find my error ?
Thank you :)