我創建了一個URL字符串:檢索得到Laravel
http://SERVER/v1/responders?latitude=48.25969809999999&longitude=11.43467940000005
路線:
Route::get('/responders', 'Responders\[email protected]');
和控制器:
public function index(Request $request) {
// Get Latitude and Longitude from request url
$latitude = $request["latitude"];
$longitude = $request["longitude"];
$responders = new Responder();
if(!isset($latitude) & !isset($longitude)) {
}
但結果是不是有什麼我期望。 URL字符串中的參數不用控制器進行分析。我是否用錯誤的方式解析它們?
我試圖轉儲我的輸入與dd($request->all());
但輸出爲NULL。由於URL正確發送,我想知道數據丟失的位置。我的路線文件不正確?
更新 難道是我的nginx配置?
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/mfserver/public;
index index.php index.html index.htm;
charset utf-8;
server_name SERVER;
location/{
try_files $uri $uri/ /index.php?query_string;
}
error_page 404 /index.php;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/mfserver/public;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
}
[獲取獲取可能的重複變量在laravel](http://stackoverflow.com/questions/15081090/getting-get-variable-in-laravel) – cb0
你可以做一個'dd($ request-> all())'並顯示結果嗎? –
結果是: 'array:1 [▼ 「query_string」=>「」 ]' – sesc360