Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class "AppBundle\Controller\HomeController" used for service "AppBundle\Controller\HomeController" cannot be found

Tags:

symfony

I am using Symfony 3.4 and when I'm trying to run server there is an error:

In RegisterControllerArgumentLocatorsPass.php line 68:

Class "AppBundle\Controller\HomeController" used for service "AppBundle\Controller\HomeController" cannot be found.

How can I deal with this problem?

like image 269
Remigiusz Remas Avatar asked Apr 21 '18 16:04

Remigiusz Remas


2 Answers

The same error manifests when a controller extends Symfony's AbstractController and does not import it.

Solved by adding the import to the controller: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

like image 136
Thomas Vangelooven Avatar answered Oct 17 '22 14:10

Thomas Vangelooven


namespace AppBundle\Controller;


use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class HomeController extends Controller
{
    /**
     * @Route('/')
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function indexAction()
    {
        return $this->render('home/index.html.twig');
    }
}

Exception thrown when handling an exception (Symfony\Component\Config\Exception\FileLoaderLoadException: [Syntax Error] Expected PlainValue, got ''' at position 7 in method AppBundle\Controller\HomeController::indexAction() in /home/remas/relevium_symfony/src/AppBundle/Controller/ (which is being imported from "/home/remas/relevium_symfony/app/config/routing.yml"). Make sure annotations are installed and enabled.)

like image 36
Remigiusz Remas Avatar answered Oct 17 '22 15:10

Remigiusz Remas