如何在调度循环 phalcon 之前获取 post 参数
How to get the post parameters in before dispatch loop phalcon
我们可以像这样在控制器中访问 post 数据:
$request = $this->di->get("request");
$data = $request->getJsonRawBody();
但是有什么方法可以访问 services.php 中的 POST 数据吗?我想在活动中访问它:
if ($event->getType() == 'beforeDispatchLoop') {
$url = 'http://localhost/curl_logging/curlLogging.php';
$router = new \Phalcon\Mvc\Router();
$uri = $router->getRewriteUri();
$controller = $dispatcher->getControllerName();
$action = $dispatcher->getActionName();
$params = array();
$params['controller'] = $controller;
$params['action'] = $action;
calling_func($url, $params);
}
提前致谢。
同样的方法,你得到你的裸体:
if ($event->getType() == 'beforeDispatchLoop') {
$request = $this->di->getRequest();
// or
// $request = $this->di->get('request');
// $request = new \Phalcon\Http\Request();
// straight from $_POST
$user = $request->getPost('login');
// using filter for delivered data
$email = $request->getPost('email', 'email');
// just obtaining full $_POST
$form = $request->getPost();
}
request documentation 下提供更多信息。
我们可以像这样在控制器中访问 post 数据:
$request = $this->di->get("request");
$data = $request->getJsonRawBody();
但是有什么方法可以访问 services.php 中的 POST 数据吗?我想在活动中访问它:
if ($event->getType() == 'beforeDispatchLoop') {
$url = 'http://localhost/curl_logging/curlLogging.php';
$router = new \Phalcon\Mvc\Router();
$uri = $router->getRewriteUri();
$controller = $dispatcher->getControllerName();
$action = $dispatcher->getActionName();
$params = array();
$params['controller'] = $controller;
$params['action'] = $action;
calling_func($url, $params);
}
提前致谢。
同样的方法,你得到你的裸体:
if ($event->getType() == 'beforeDispatchLoop') {
$request = $this->di->getRequest();
// or
// $request = $this->di->get('request');
// $request = new \Phalcon\Http\Request();
// straight from $_POST
$user = $request->getPost('login');
// using filter for delivered data
$email = $request->getPost('email', 'email');
// just obtaining full $_POST
$form = $request->getPost();
}
request documentation 下提供更多信息。