Php 创建参数化restful Web服务时未找到路由错误
我使用Php 创建参数化restful Web服务时未找到路由错误,php,symfony,fosrestbundle,Php,Symfony,Fosrestbundle,我使用symfony 2.2.3和FOSRestBundle来实现Restfulwebservices 这是我的代码,但当我启动以下url时,我得到以下错误 No route found for "GET /business/john" 这是控制器代码 use FOS\RestBundle\Controller\Annotations as Rest; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use S
symfony 2.2.3
和FOSRestBundle
来实现Restful
webservices
这是我的代码,但当我启动以下url时,我得到以下错误
No route found for "GET /business/john"
这是控制器代码
use FOS\RestBundle\Controller\Annotations as Rest;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Routing\ClassResourceInterface;
class BusinessController extends Controller {
public function getBusinessAction($para){
return new JsonResponse(array('name' => $para));
}
}
这是我的网址
http://localhost/symfony/web/app_dev.php/business/john
这是我的路线
如果我从url和函数getBusinessAction
中删除参数,则它可以工作,但不能与参数一起工作/
_business:
resource: "@HubHomeBundle/Controller/BusinessController.php"
type: rest
更新
内部app/confing/routing.yml
hub_home:
resource: "@HubHomeBundle/Resources/config/routing.yml"
只是想确定一下,这是来自HubHomeBundle/Resources/config/routing.yml吗
_business:
resource: "@HubHomeBundle/Controller/BusinessController.php"
type: rest
如果是,请尝试编辑它并将其更改为:
_business:
resource: HubHomeBundle\Controller\BusinessController
type: rest
“resource”标记的值应该是控制器类的完全限定名,而不是文件的路径您是否在app/config/routing.yml中注册了捆绑路由?同样在终端类型php应用程序/控制台路由器中:debug。它将列出所有可用的路由。我已经编辑了这个问题,但我不知道如何使用
app/console router:debug
转到项目的根目录(在那里你可以看到app、web、config、日志、资源目录)并运行“php app/console router:debug”你的输出是什么?