I have this extremely simple code snipped in my controller, which always did its job of getting a php varaible from URL:
URL: wholesaleeventeditions/create?event=36
$wholesaleevent = Input::get('event');
if(isset($wholesaleevent)) {
$event = $wholesaleevent;
} else {
$event = null;
}
Now, after I have migrated to new VPS service, Laravel 8 cannot handle the variable. It must be server problem, as my obsolete app build on Laravel 5.8 started to produce similar effect.
My environments:
- LOCAL: Windows 10, php 7.4.13 vc 15 TS, Laravel 8 and Laravel 5.8, Apache 2.4.46 VS16 (on newest Laragon 5.0)
- REMOTE: Ubuntu 20.10, Nginx 1.18.0, php 7.4.9
- A Laravel version note: Mu best guess is that it must be something with the Ubuntu 20.10 server config, as the error broke down a separate Laravel 5.8 app of mine. I have no clue though I would blame a quirk in php 7.4.
What I tried but to no avail:
- In desperation, I changed
$input = Input::get('event');
to$input = Input::all();
and then$event = $wholesaleevent['event'];
. The code works on local, but on remote server it produces `Undefined index: event’ error. - I have disabled SSL protection in my server (and rebooted the server to make sure no caches interfere). In other words: I have changed server to
http
only and accessed it with a separate browser by typing url containinghttp
only.
2
Answers
or
If you have an error in both of your Laravels, then it is a NGINX misconfiguration.
This is the most basic config for it, see if you are missing anything:
Also, a small tip for your code: If you are not using the value again (you stored it at
$event
), you can do this to have better code:get
has a second parameter that, by default, isnull
. That parameter will be the default value if'event'
is not present in the URI. Also, try always to useRequest
($request
) and not plainInput
.