Ciąglę walczę z przykładem z książki, który opisałem we wczesniejszym poście. Tym razem męczę się aby wyświetlić dahsboard.view.php
index.php
require('config.php');
use Hajduk\Shortener;
$processor = new \Hajduk\Shortener\RequestProcessor();
switch ($_SERVER['HTTP_HOST']) {
case ROOT_LANDING_URL:
$processor->processLandingRequest($_SERVER['REQUEST_URI']);
break;
case ROOT_APP_URL:
$processor->processAppRequest($_SERVER['REQUEST_URI']);
break;
case ROOT_SHORT_URL:
$processor->processShortRequest($_SERVER['REQUEST_URI']);
break;
default:
header("Location:http://" . ROOT_LANDING_URL
); break;
}
config.php
//Define DB params
define("DB_HOST", "localhost");
//Define URL
define("ROOT_LANDING_URL", "localhost"); define("ROOT_APP_URL", "app.localhost"); define("ROOT_SHORT_URL", "riy");
foreach (glob("app/*.php") as $filename) { include $filename;
}
include("RequestProcessor.php");
RequestProcessor.php
namespace Hajduk\Shortener;
class RequestProcessor
{
public function processShortRequest($request)
{
$shortener = new Shortener();
$shortener->RedirectToDestinationUrl(
'/',
'',
$request
)
);
}
public function processAppRequest($request)
{
$dashboard = new Dashboard($request);
$dashboard->ProcessRequest();
}
public function processLandingRequest($request)
{
require("landing.view.php");
}
}
I wreszcie Dashboard.php który to ma wyświetlić dashboard.view.php ale wygląda na to że mi go nie wyświetla
namespace Hajduk\Shortener;
class Dashboard
{
private $request;
private $post;
private $get;
public function __construct($request)
{
$requestString = explode("?", $request); $this->request = empty($requestString) ?
$request : $requestString[0
]; }
public function processRequest()
{
if (!$this->request) {
return;
}
$this->post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
$this->get = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
switch ($this->request) {
case "/":
$this->showDashboard();
break;
}
}
private function showDashboard()
{
$clicks = 1020;
$count = 100;
require("app/views/dashboard.view.php");
}
}
Po wpisaniu w przeglądarkę localhost/stronka wyświetla mi się landing page, czyli ok. Jednak po wpisaniu app.localhost/stronka nie wyświetla się nic a wg mojego rozumienia tego kodu powinno się załadować dashboard.view.php
Co robię nie tak? Jaki adres wpisać żeby odpaliła metoda showDashboard() ?
Dzięki.
PS. nospor - cierpliwości (IMG:
style_emoticons/default/wink.gif)
Ten post edytował sadistic_son 21.12.2022, 13:30:11