Hej, piszę dla nauki framework. Utknąłem w środku routingu, odbieram kontroler, akcje i parametry z adresu i teraz nie wiem, jak mam wywołać dany kontroler. Może ktoś mnie nakieruje? Oto mój router:
<?php
class Router
{
public $uri;
public $controller;
public $method;
public $params = array();
public function __construct()
{
$returnPath = new Uri;
$this->uri = $returnPath->returnPath();
$this->parseRoutes();
}
private function parseRoutes()
{
echo 'default controller'; }
else
{
$this->setRoutes($segments[0]);
}
}
private function setRoutes($segments)
{
$this->controller = $segments[0];
if (!empty($segments[1
])) {
$this->method = $segments[1];
for ($i = 2; $i < count($segments); $i++) {
$this->params[$i] = $segments[$i];
}
}
else
{
$this->method = 'index';
}
/* TEST: */
echo 'Kontroler: '. $this->controller; echo '<br />Akcja: '. $this->method; for ($i = 2; $i < count($segments); $i++) {
$j = $i - 1;
echo '<br />Parametr '. $j .': '. $this->params[$i]; }
}
}