84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
工作中需要构建基于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/...