84669 人学习
152542 人学习
20005 人学习
5487 人学习
7821 人学习
359900 人学习
3350 人学习
180660 人学习
48569 人学习
18603 人学习
40936 人学习
1549 人学习
1183 人学习
32909 人学习
工作中需要构建基于RESTful风格的API, 当http method等于PATCH时,没有$this->request->getPatch()方法,用$this->request->getPut()或者$this->request->getPost()都没法获取提交上来的数据。
PATCH
$this->request->getPatch()
$this->request->getPut()
$this->request->getPost()
有没有方法能方便的获取到patch data呢?
认证高级PHP讲师
没有在网上找到解决方案,自己基于phalcon的request对象实现了getPatch()和hasPatch()。
getPatch()
hasPatch()
具体的用法:
// get all patch data... $params = $this->request->getPatch(); // try to get username from patch data $name = $this->request->getPatch('username'); // try to get and format price $price = $this->request->getPatch('price', 'float!');
只需要在依赖注入自己的Request class,就可以在项目中调用getPatch()方法
$di->set('request', function() { return new \Request(); }, true);
具体的代码在Github:
https://github.com/baohanddd/...
没有在网上找到解决方案,自己基于phalcon的request对象实现了
getPatch()
和hasPatch()
。具体的用法:
只需要在依赖注入自己的Request class,就可以在项目中调用getPatch()方法
具体的代码在Github:
https://github.com/baohanddd/...