REST GET with parameter ignored, PHP Symfony 3 Mpdf

大兔子大兔子 提交于 2019-12-01 14:57:58

http://localhost:8000/create?htmlSource=PATH-TO-FILE-LOCALLY

("/create/{htmlSource}")

These paths do not match. First path consists of domain name, and route create, while second path has route "create" + slash + wildcard.

Query parameters are not defined within routing annotation. Instead, access them inside controller, using

public function createPDFFromSourceAction(Request $request)
{
    $htmlSource = $request->query->get('htmlSource'); // query string parameter
    $somethingElse = $request->request->get('somethingElse'); //POST request parameter
    ...
}

Symfony will pass Request object inside the controller for you.

As for your other question, GET requests are usually used for things that do not change the state of the application, and POST/PUT/PATCH/DELETE requests change the state. Since you are uploading something, use POST request.

For your 'side note' you should ask another question instead.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!