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?

  1. can fast routes?
  2. can slim?
  3. is there framework can achieve want?
  4. 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

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -