How is this Laravel related?
PHPUnit Missing $_SERVER['REQUEST_URI']
I use the $_SERVER['REQUEST_URI'] variable in the Footer of my Website, which displays on all pages.
I'm using this variable for a reporting system, so that when a link is clicked on, I know where the User came from, and thus know what page they initially clicked "Report Error" on.
This feature works just fine. However, when I'm running PHPUnit, I discovered that the 'REQUEST_URI' index does not exist within the $_SERVER variable.
Seeing as I'd like to be able to test my Reporting System, how can I mock this address? Is there a better way of determining this address?
I don't want to hard-code it, because redirects may break it. I don't want to just ignore the variable, because then I can't test Reporting within my Application.
If you use Laravel you shouldn't be using the $_SERVER variables at all. If you want that kind of stuff you can use the following
$uri = Request::server('REQUEST_URI');
However you can also get the last requested page much simpler
$url = URL::previous();
Please or to participate in this conversation.