早上好。
我的控制器如下所示:
class OrderController extends AbstractController
{
/**
* @Route("/order", name="order")
*/
public function index(Request $request)
{
var_dump($request->request->all());die;
return $this->json([
'message' => 'Welcome to your new controller!',
'path' => 'src/Controller/OrderController.php',
]);
}
}
当我跑的时候
php bin\console server:run
在浏览器中访问localhost/order,我得到了它应该得到的页面。如果我用
curl http://127.0.0.1:8000/order
我的请求如下:
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '
{'json':{
"id": "1",
"customer-id": "1",
"items": [
{
"product-id": "B102",
"quantity": "10",
"unit-price": "4.99",
"total": "49.90"
}
],
"total": "49.90"
}}' http://127.0.0.1:8000/order