steampixel/simplePHPRouter

Fixed Navigation

steampixel opened this issue · 2 comments

Hey @ImMaax,

Fyi: I added back the navi() function to the index.php
The reason for that is that nothing should be echoed before calling the run() method of the router. In some cases it will return 404 and 405 headers. This will only work if nothing was echoed before.

I will update this with my next push.

I also had the idea to completely remove the header() calls from the class. So the users can decide on their own how to handle those cases inside the callback functions. What do you think?

Removing the header() calls would give the users more flexibility (like redirecting the user; sending a 404 and 301 doesn't work), which is a good thing. On the other hand, it makes a lot of sense to send the correct status codes inside the corresponding methods, as it might save the users some confusion (why is the 404 route triggered, but the status is 200 OK?).

My conclusion would be to remove the automatic header() calls, because of the flexibility gain. I'd recommend to document that change so the users are informed and can add their own header() calls.

I have now removed the header() calls and put them into the index.php instead.