I’ve been working through the printed book using the recommended windows setup of Vagrant, VirtualBox, Git and am now stuck on pg. 375.
Both the code I’ve typed by hand and the downloaded versions of CMS-Controller-Rewrite and CMS-EntryPoint-Class result in multiple errors for “Undefined variable: page… yadda yadda” when loading index.php, “joke/edit” when editing, and if there is no existing $route set. The error does not occur when loading “joke/list”, “joke/edit” when adding a joke and deleting a joke.
I’m not sure how to fix this. It seems like the $page variable isn’t passed when using the “header('location: ’ . strtolower($route));” redirect?
“Undefined variable: page… yadda yadda”.
The yadda yadda is important. It tells you exactly what line caused the failure. Go look at the line that it says.
Sorry, I left out the yadda yadda because it used to be reproducible (on my machine, presumably for others if using the same code) but for whatever reason, running the same code/project this morning yields no errors?
The problem is almost certainly the URL. That page maps a URL to the controller action. If you go to /thisdoesnotexist it won’t match any of the if statements and the $page variable is not set, giving the error you had.