-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't attach resource to root of mount point #174
Comments
I should also mention that everything was actually working fine with the "/" URI for MainResource on Apache, but when I started testing on NGINX, I began getting the error. |
I'm curious of the difference with Apache vs NGINX, I'm assuming you were using mod_rewrite with Apache, and if so what were did the rules look like? The reason of course are because sometimes we forget to emulate all the mod_rewrite settings in NGINX when making a switch, myself included. Please note, you can use Github flavored markdown for code snippets. $this->one = "is php"; |
My implementations between Apache and NGINX are very similar (see below). Apache (.htaccess located in /path/to/app)
NGINX
Thanks for the suggestion on GFM I'm brand new to NGINX, so it's entirely possible (likely) that I made a mistake or left something out, so any suggestions would be much appreciated. |
Hmm, just from looking I can't really see anything wrong, but I would make a suggestion, if you can, to var_dump/print_r everything from I have a feeling it's something that might be able to be fixed with a |
Here are the $_SERVER outputs from both. $_SERVER from Apache
$_SERVER from NGINX
Clearly, the DOCUMENT_URI and REQUEST_URI values are slightly different, but would that prevent the resource from attaching to "/"? |
I think I need more time to look into this, but I'm leaning toward this being the (start of the) culprit. First this: Lines 187 to 191 in 3a00507
Then this: tonic/src/Tonic/Application.php Line 31 in 3a00507
I do not see anywhere in the code where it handles the baseUri by stripping it, but I am not confident enough with the code right now to see where the matching is actually comparing resource paths with some concatenated version of This is just my initial finding to get somewhere to tracking this down. It does look like this should be accounted for, but sorry I'm unsure of the exact problem right now. At one point I had the whole test suite for Tonic setup, but not on my current machine :/ I do however still believe this is a platform specific issue, that I still definitely think is worth tracking down. |
Based on your suggestion, I added the following snippet to the getURIFromEnvironment() method and it worked. elseif (isset($_SERVER['REQUEST_URI']) && isset($_SERVER['SCRIPT_NAME'])) { // use redirection URL from NGINX environment
$dirname = dirname($_SERVER['SCRIPT_NAME']);
$uri = substr($_SERVER['REQUEST_URI'], strlen($dirname == DIRECTORY_SEPARATOR ? '' : $dirname));
} |
I don't seem to be able to attach a resource to the root of my mount point.
I have defined a mount point of /api for my app. I also have a resource named MainResource with the URI defined as "@uri /". All of my other routes work, but when I try to access http://mysite/api/, Tonic throws an exception stating that "Resource matching URI "/api" not found". I was able to get it to work by adding a condition to the mount() method that checks to see if the URI equals "/", and if so, don't attach the URI to the uriSpace. Am I doing something wrong? Is there another way to attach a resource to "/". If not, any can we get this fix pulled in?
The text was updated successfully, but these errors were encountered: