Autoloader et RuntimeException
Bonjour à tous !
J'essaye de me familiariser avec Symfony2.
Je tente de créer une page de contact simple, mais lorsque je lance le navigateur j'obtiens l'erreur suivante :
Code:
RuntimeException: The autoloader expected class "Yekoo\GroupeBundle\Controller\ContactController" to be defined in file "C:\Program Files\wamp\www\Symfony\app/../src\Yekoo\GroupeBundle\Controller\ContactController.php". You probably have a typo in the namespace or the class name. (uncaught exception) at C:\Program Files\wamp\www\Symfony\vendor\symfony\src\Symfony\Component\ClassLoader\DebugUniversalClassLoader.php line 58
Pour infos :
- J'ai créer mon bundle "Groupe"
- Il est référencé dans le fichier AppKernel.php
- J'ai créé une route :
Code:
1 2 3
| contact:
pattern: /contact/
defaults: { _controller: YekooGroupeBundle:Contact:index } |
- J'ai créé le controller ContactController (Yekoo\GroupeBundle\Controller\ContactController.php)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| <?php
namespace Yekoo\GroupeBundle\Controller;
namespace Yekoo\GroupeBundle\Form;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class ContactController extends Controller
{
/**
* @Template()
*/
public function indexAction()
{
$form = $this->get('form.factory')->create(new ContactType());
$request = $this->get('request');
if ('POST' == $request->getMethod()) {
$form->bindRequest($request);
if ($form->isValid()) {
$mailer = $this->get('mailer');
// .. setup a message and send it
// http://symfony.com/doc/current/cookbook/email.html
$this->get('session')->setFlash('notice', 'Message sent!');
return new RedirectResponse($this->generateUrl('contact'));
}
}
return array('form' => $form->createView());
}
} |
- J'ai créé ma vue (Yekoo\GroupeBundle\Resources\views\Contact\index.html.twig)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| {% block title "Symfony - Formulaire de contact" %}
{% block content %}
<form action="{{ path('contact') }}" method="POST" id="contact_form">
{{ form_errors(form) }}
{{ form_row(form.nom) }}
{{ form_row(form.email) }}
{{ form_row(form.message) }}
{{ form_rest(form) }}
<input type="submit" value="Send" class="symfony-button-grey" />
</form>
{% endblock %} |
J'ai bien compris qu'il y a visiblement une erreur dans le nommage des namespaces et/ou classes... Mais je ne la trouve pas.
Avez vous une idée pour m'aider à résoudre ce problème ?
Je vous remercie.
Yekoo.