我正在尝试让我的控制器与 param fetcher 一起工作。我做了文档中指定的所有说明。所以我有:配置fos_rest.yml:
fos_rest:
param_fetcher_listener: 'force'
view:
formats:
json: true
xml: false
rss: false
mime_types:
json: ['application/json', 'application/x-json', 'application/vnd.example-com.foo+json']
png: 'image/png'
failed_validation: HTTP_BAD_REQUEST
default_engine: twig
view_response_listener: 'force'
format_listener:
default_priorities:
- json
routing_loader:
default_format: json
sensio_framework_extra:视图:{注解:假}路由器:{注解:真}
还有我的控制器
<?php
namespace Push\PointsBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use FOS\RestBundle\View\View;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Request\ParamFetcherInterface;
use FOS\RestBundle\Controller\Annotations\RequestParam;
use FOS\RestBundle\Request\ParamFetcher;
class RestController extends Controller
{
/**
* @QueryParam(name="latitude", requirements="[0-9.]+", default="0", description="")
* @ApiDoc()
*/
public function checkPointsAction(ParamFetcher $params)
{
$view = new View();
return $this->get('fos_rest.view_handler')->handle($view);
}
}
当我调用方法时,我得到:
控制器 "Push\PointsBundle\Controller\RestController::checkPointsAction()" 要求您为 "$params" 参数提供一个值(因为没有默认值或因为在此参数之后有一个非可选参数)。
我做错了什么或错过了什么?谢谢你。