Indatus / ranger

MIT License
84 stars 7 forks source link

Doesn't work on paths other than root #1

Closed twmbx closed 10 years ago

twmbx commented 10 years ago

Edit: Laravel version is 4.1

Not sure where the bug is; assume it's to do with which methods are used by RequestContainer.php to obtain the parameters of the current request.

the all() from Illuminate\Http\Request returns the path of the request in addition to any query params and this ends up always being the first array value.

ie: the $inputs array used in make() of QueryBuilderFactory.php will always have the path as the first item: screenshot from 2014-05-02 14 57 00

Considering the logic in the make() this will always cause an InvalidInputException to be thrown.

My current dirty fix is to unset( $inputs[0] ) before the foreach executes.

cegrif01 commented 10 years ago

Could you send me an example of the full http request that you are sending? ie) http://www.example.com/api/v1/towns?searchParams[property]=name&searchParams[operator]=like&searchParams[value]=%Ch%

twmbx commented 10 years ago

http://www.example.com/api/v1/towns http://www.example.com/api/v1/towns/1 http://www.example.com/api/v1/towns?searchParams[property]=name&searchParams[operator]=like&searchParams[value]=%Nd%

all of the above will throw InvalidInputException.

found it by using dd() like screenshot: screenshot from 2014-05-02 18 30 42

the first index of $input will be '/api/v1/towns' (edit: the one case will be 'api/v1/towns/1' in each case and won't match any of the if statements in the foreach loop. definitely works if i unset the first index of the array however

cegrif01 commented 10 years ago

This issue almost certainly sounds like an apache rewrite issue. I would check in your vhost config and your .htaccess files. Here is an example of my public .htaccess file:

Options -MultiViews ``` RewriteEngine On # Redirect Trailing Slashes... RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] ```

I'm not very familiar with nginx, but if you are using that I would start by checking out those config settings. In the mean time, I will see if I can come up with a better way of parsing so that JUST the query parameters (anything after the ?) get evaluated. You probably won't be the last person that will have this issue, especially if they have a more customized apache or nginx setup.

Let me know if changing the web server config settings don't work for you.

twmbx commented 10 years ago

You were right! Yes, I am using nginx. I've never had an issue with my laravel projects up until now but I went hunting for a better possible set of settings than I have for my virtual host and found this: http://phawk.co.uk/blog/laravel-4-nginx-config/

Fixed it right up. Maybe a note in the readme file for anyone with a similar issue?

cegrif01 commented 10 years ago

Ok, I added an Problem and Solution section to the readme file. Thank you for your feedback. Let me know if you have any more problems. I'm going to close this issue.