0

我收到以下错误:

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.

我拥有的控制器代码实际上是:

namespace Acme\HelloBundle\Controller;

use Symfony\Component\HttpFoundation\Response;

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

知道这是为什么吗?

4

2 回答 2

3

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

只需在开头添加 "*LESS_THAN*"?php 标签。试试看是否有效。

于 2013-01-30T02:39:29.153 回答
0

你的控制器应该扩展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>');
    }
}
于 2012-08-28T07:33:33.457 回答