I'm trying to make a simplest and a very basic request-response system in php, similar to as in Yii-2.0. For that I was reading inside the basic\web\index.php there is:
$application = new yii\web\Application($config);
$application->run();
I dug deeper, but couldn't figure out how the process is carried out.
Here is what I found:
the run()
method in yii\web\application has this (excluding the triggers):
$response = $this->handleRequest($this->getRequest());
$response->send();
return $response->exitStatus;
handleRequest is just an abstract function yet,
abstract public function handleRequest($request);
So I basically don't understand how this code is returning a response?
UPDATE:
As answered here is the handleRequest
function for quick referene:
public function handleRequest($request)
{
if (empty($this->catchAll)) {
list ($route, $params) = $request->resolve();
} else {
$route = $this->catchAll[0];
$params = $this->catchAll;
unset($params[0]);
}
try {
Yii::trace("Route requested: '$route'", __METHOD__);
$this->requestedRoute = $route;
$result = $this->runAction($route, $params);
if ($result instanceof Response) {
return $result;
} else {
$response = $this->getResponse();
if ($result !== null) {
$response->data = $result;
}
return $response;
}
} catch (InvalidRouteException $e) {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'), $e->getCode(), $e);
}
}
i'm in a process to figure out the whole process. will post as an answer as soon as I get a full hold of it. Probably we shall make a better flowchart than Yii documentation. :)