我試圖讓我的PARAM提取器控制器的工作。我做了文檔中指定的所有說明。所以,我有什麼: 配置 fos_rest.yml: FOSRestBundle不能得到PARAM提取器
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);
}
}
當我打電話給我的方法時:
控制器 「推\ PointsBundle \控制器\ RestController :: checkPointsAction()」 要求您爲提供一個值「$ PARAMS」的說法(因爲 沒有默認值,或因爲存在非可選參數 後這個)。
我做錯了什麼或錯過了什麼?謝謝。
你解決了這個問題嗎?我有完全相同的問題。 – MartinElvar