0

I am getting the following error:

The autoloader expected class "Acme\HelloBundle\Controller\HelloController" to be defined in file "/var/www/Symfony/app/../src/Acme/HelloBundle/Controller/HelloController.php". The file was found but the class was not in it, the class name or namespace probably has a typo.

The controller code I have is actually:

namespace Acme\HelloBundle\Controller;

use Symfony\Component\HttpFoundation\Response;

class HelloController
{
    public function indexAction($name)
    {
        return new Response('<html><body>Hello '.$name.'!</body></html>');
    }
}

any idea why this is?

Elnur Abdurrakhimov
  • 44,533
  • 10
  • 148
  • 133
adit
  • 32,574
  • 72
  • 229
  • 373

2 Answers2

3

<?php namespace Acme\HelloBundle\Controller; ....

Just add the "*LESS_THAN*"?php tag at the beginning. Try if works.

dum3
  • 31
  • 2
  • Seems very common (hit me too); same thing [Symfony Database Tutorial code error][http://stackoverflow.com/questions/7482320/symfony-database-tutorial-code-error/7483225], [symfony2 Unable to find controller][http://stackoverflow.com/questions/5662876/symfony2-unable-to-find-controller?rq=1], and probably others. – toddkaufmann Feb 23 '13 at 16:59
0

Your controller should extend Symfony\Bundle\FrameworkBundle\Controller\Controller

namespace Acme\HelloBundle\Controller;

use Symfony\Component\HttpFoundation\Response;
use namespace Acme\HelloBundle\Controller;


class HelloController extends Controller
{
    public function indexAction($name)
    {
        return new Response('<html><body>Hello '.$name.'!</body></html>');
    }
}
Julien Fastré
  • 1,008
  • 13
  • 20