php - Slim Framework Optional Params Routes -
i'm new php , i'm using slim framework develop simple rest api.
according docs, slim uses fastroute.
i have route optional params (vendor , quantity) that:
path/items/{id}/{name}/{price}[/{vendor}[/{quantity}]]
the problem if leave vendor blank value of quantity goes vendor , quantity not filled. understand fast routes can't achieve that. but, how can it?
- can fast routes?
- can slim?
- is there framework can achieve want?
- should use query strings? (i think answer, need more knowledge).
thank you.
if going have optional parameters, of same types , can sent in order, either use query strings, or have fixed format add 0 instead of omitting it. example "vendor" isn't set:
/10/somename/15/0/12
then parameters aren't optional in url/route can handle in controller instead, ignoring them if param zero.
Comments
Post a Comment