【发布时间】:2016-06-02 10:05:43
【问题描述】:
我是restful api的新手,遇到了一个问题,问题是:当我用delete方法请求destroy和用post方法存储时,都会返回500错误。但是我用get方法请求索引和显示,两者没问题。有什么问题?这是我的代码和要求:
删除 http://***.com/RestfulPrac/public/customers/10000001
获取 http://***.com/RestfulPrac/public/customers/10000001
发布 http://***.com/RestfulPrac/public/customers
class CustomersController extends Controller
{
public function index(){
$customersInfo = customers::all();
return $customersInfo;
}
public function show($cust_id){
$customer = customers::where('cust_id',$cust_id)->first();
return $customer;
}
public function store()
{
echo "store";
}
public function destroy()
{
return "success";
}
}
Route::resource('customers','CustomersController');
apache access.log : "DELETE /RestfulPrac/public/customers/1000000001 HTTP/1.0" 500 20246 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
apache 错误日志: [Thu Jun 02 09:09:24.324782 2016] [negotiation:error] [pid 4328:tid 1676] [client 127.0.0.1:4940] AH00690:没有可接受的变体:D:/XAMPP/apache/error/HTTP_NOT_FOUND.html。变量
laravel.log: local.ERROR:F:\PhpstormProjects\RestfulPrac\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php 中的异常“Illuminate\Session\TokenMismatchException”:67 堆栈跟踪:
如果有人可以帮助我,我将不胜感激!提前致谢!
【问题讨论】:
-
你有没有查看 laravel 的错误日志,看看是否有任何内容,或者 webserver 的错误日志?
-
@lagbox 我已经编辑了帖子
-
显示和索引方法对我来说没问题..但是存储和销毁不起作用
-
你能检查一下存储/日志中的laravel日志和你的apache error.log吗
标签: laravel laravel-5 laravel-routing laravel-request