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?

3
  • 1
    Everything looks ok. However, all my controllers extend Symfony\Bundle\FrameworkBundle\Controller\Controller;, but I'm not sure if that has anything to do with it Commented Aug 28, 2012 at 6:40
  • Probably typo in filename or in folder name Commented Aug 28, 2012 at 6:47
  • which filename and folder? I don't see any typo Commented Aug 28, 2012 at 6:56

2 Answers 2

3

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

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

Sign up to request clarification or add additional context in comments.

1 Comment

Seems very common (hit me too); same thing [Symfony Database Tutorial code error][stackoverflow.com/questions/7482320/…, [symfony2 Unable to find controller][stackoverflow.com/questions/5662876/…, and probably others.
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>');
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.