Laravel获得路线工作,发布不要 [英] Laravel get routes work, post don't
问题描述
我只是无法弄清楚,为什么在我的本地环境中,以下路径完美工作......并且在我提供的Staging环境中,为了测试代码,它不能像所假定的那样工作
路由:
Route :: controller(Controller :: detect ));
Route :: get('api',array(
'as'='>'api_index',
'uses '=>'api @ index',
));
Route :: get('api /(:any)/(:any)','api。(:1)@(:2)');
Route :: post('api /(:any)/(:any)','api。(:1)@(:2)');
Route :: put('api /(:any)/(:any)','api。(:1)@(:2)');
Route :: delete('api /(:any)/(:any)','api。(:1)@(:2)');
这个问题出现在我的帖子请求中,因为他们只是不会被发现而且总是返回一个404没有请求。示例:
POST
http://暂存。 test.com/api
- > 404
POST
http:// staging.test.com/api/user
- > 404
POST
http://staging.test.com/api/user/session
- > 404
凡所有的上述测试,在我的本地环境中工作。 GET
方法有效(除了 POST
我已经测试过)之外的唯一一个方法)
那么我错过了什么?
UPDATE
试图改变 Routes ::
,然后尝试了不同的方法...但仍然是相同的结果
已经尝试过了:
Route :: controller(array('api.user','api.device' ));
但是只能用它:
路线::控制器( 'api.user');
Route :: controller('api.device');
I just can't figure it out, why on my local environment the following routes work perfectly.... and on a Staging environment I have been provided, to test the code, it doesn't work as supposed to
Routes:
Route::controller(Controller::detect());
...
Route::get('api', array(
'as' => 'api_index',
'uses' => 'api@index',
));
Route::get('api/(:any)/(:any)', 'api.(:1)@(:2)');
Route::post('api/(:any)/(:any)', 'api.(:1)@(:2)');
Route::put('api/(:any)/(:any)', 'api.(:1)@(:2)');
Route::delete('api/(:any)/(:any)', 'api.(:1)@(:2)');
The problem stands at my post requests, as they just won't be found and always returning a 404 no mather the request. Example:
POST
http://staging.test.com/api
-> 404POST
http://staging.test.com/api/user
-> 404POST
http://staging.test.com/api/user/session
-> 404
Where all of the above tests, work in my local environment. The GET
method works (the only one besides POST
that I have tested)
So what am I missing?
UPDATE
Tried changing the order of the Routes::
, and tried the different methods... but still the same result
Just as @TheShiftExchange said, it seams to be the buggy Controller::detect()
's fault.
Have tried also:
Route::controller(array('api.user', 'api.device'));
But only got it to work with:
Route::controller('api.user');
Route::controller('api.device');
这篇关于Laravel获得路线工作,发布不要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!