Controller not found: service "AppBundle/Controller/TestController.php" does not exist

I get the error Controller not found: service "AppBundle / Controller / TestController.php" does not exist
but i don’t know how to debug it. Can someone please help me !?
Is it possible that the error comes from the routing or it is something else !?
I just want to clarify that I use Symfony 3.4.

Here is the extract from the TestController.php code

namespace AppBundleController; 

use AppBundleEntityTask;
use AppBundleFormTaskType;
use SymfonyBundleFrameworkBundleControllerController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentRoutingAnnotationRoute;

/**
* Description of TestController
*
* @author m.andriamil
* @Route("test/form-test")
*/
class TestController extends Controller {

   /**
   * @Route("/", name="test")
   */
    public function newAction(Request $request) {
    // creates a task and gives it some dummy data for this example
    $task = new Task();
    $task->setTask('Write a blog post');
    $task->setDueDate(new DateTime('tomorrow'));

    $form = $this->get('form.factory')->createNamed('addTask', TaskType::class, $task);

    $form->handleRequest($request);

    $validator = $this->get('validator');
    $errors = $validator->validate($form);
    if (count($editErrors) > 0) {
        $errorsString = (string) $editErrors;

        return new Response($errorsString);
    }
    echo('------------------------------------------------------------------------'.$form->isSubmitted().' && '.$form->isValid());
    if ($form->isSubmitted() && $form->isValid()) {
        // $form->getData() holds the submitted values
        // but, the original `$task` variable has also been updated
        $task = $form->getData();

        // ... perform some action, such as saving the task to the database
        // for example, if Task is a Doctrine entity, save it!
        // $entityManager = $this->getDoctrine()->getManager();
        // $entityManager->persist($task);
        // $entityManager->flush();
        return new Response('<h1>-----------------------------------------------------------------------------------OK</h1>');
    }

    return $this->render('default/index.html.twig', [
                'form' => $form->createView(),
                'errors' => $errors,
    ]);
}

}`

thank you in advance

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *