如何在Lumen中添加查询参数?

Ris*_*abh 6 lumen

我想知道如何向Lumen中的路由添加查询参数

这是我创建的路线的一个例子

$app->get('/product/{apikey}','ProductController@getProduct');
Run Code Online (Sandbox Code Playgroud)

这在我使用时有效

http://api.lumenbased.com/product/10920918

但我想像这样使用它

http://api.lumenbased.com/product/?apikey=10920918

我试过这个

$app->get('/product/?apikey={apikey}','ProductController@getProduct');
Run Code Online (Sandbox Code Playgroud)

但这给了我MethodNotAllowedHttpException

我想知道如何在Lumen中使用查询参数编写路由?

cee*_*yoz 7

做就是了:

$app->get('/product','ProductController@getProduct');
Run Code Online (Sandbox Code Playgroud)

并使用:

$request->get('apikey')
Run Code Online (Sandbox Code Playgroud)

ProductController@getProduct功能中.

(也就是说,通过中间件更好地验证API密钥......)