Routing to URL with query strings
williamoconnorme opened this issue · 1 comments
Hey steampixel, is there any creative way you're dealing with routing to files with query strings appended?
e.g.
Route::add('/orders/new', function () { require_once (__DIR__ . '/views/orders.php?status=new'); });
The above example does not work of course but maybe it will help explain my issue. The require_once() and include() functions are for directly linking to a file on the filesystem, so it thinks the query string is a part of the file name, whereas the web server will interpret it as a normal query string to pass to our file in the request
After playing around, I found I could achieve the same by just setting the query string variable before including the file I want to route to
e.g.
Route::add('/orders/processed', function () { $_GET['status'] = "processed"; include(__DIR__ . '/views/orders.php'); });