2013-02-17 82 views
1

在一個新的L4的安裝:Laravel 4 Input :: all()將請求路徑附加到輸入數組?

Route.php

Route::post('/test', '[email protected]'); 

TestController.php

class TestController extends Controller { 


     /** 
     * Store a newly created resource in storage. 
     * 
     * @return Response 
     */ 
     public function store() 

     { 

       print_r(Input::get()); 
       // 
     } 

} 

冰壺URL

curl --data "param1=value1&param2=value2" http://example.com/test 

輸出

Array 
(
    [param1] => value1 
    [param2] => value2 
    [/test] => 
) 

什麼是請求URI來這裏幹什麼? PS:使用Nginx/Php-fpm堆棧應該很重要。

回答

6

原來是我使用的ngixn clean URL片段。

if (!-d $request_filename) 
    { 
     rewrite ^/(.*)$ /index.php?/$1 last; 
    } 

TO:從改成了

try_files $uri $uri/ /index.php?$args; 

,它正在最後一次更新之前罰款,但。

1

問題是其他地方在你的代碼,而不是Laravel 4

我只是跑使用Laravel 4的最新測試構建了以下測試:

Route::post('/test', function() 
{ 
    print_r($_POST); 
    print_r(Input::get()); 
}); 

觀點:

<h1>Test</h1> 
<form method="post" action=""> 
    <input type="hidden" name="test1" id="test1" value="testfield1" /> 
    <input type="hidden" name="test2" id="test2" value="testfield2" /> 
    <button type="submit">Submit</button> 
</form> 

結果:

Array ([test1] => testfield1 [test2] => testfield2) 
Array ([test1] => testfield1 [test2] => testfield2) 

您是否在代碼中的其他任何地方使用輸入類,或許是在過濾器之前?

在你的代碼中試試上面的代碼測試 - 它給你什麼結果?

+0

感謝您的輸入,我確實嘗試了全新的安裝並且工作正常,現在奇怪的是我從應用程序的所有代碼中僅留下了一個測試控制器,並且仍然不斷收到此錯誤。我似乎無法將其縮小到它發生的位置。 – silkAdmin 2013-02-17 14:10:24

+0

您最近是否做過作曲家更新,忘記更新應用程序核心本身? – Laurence 2013-02-17 14:13:48

+0

是的一切都是最新 – silkAdmin 2013-02-17 14:17:00