Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Przekierowanie a ładowanie metody
sadistic_son
post
Post #1





Grupa: Zarejestrowani
Postów: 1 495
Pomógł: 245
Dołączył: 1.07.2009
Skąd: Bydgoszcz

Ostrzeżenie: (0%)
-----


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
  1. require('config.php');
  2.  
  3. use Hajduk\Shortener;
  4.  
  5. $processor = new \Hajduk\Shortener\RequestProcessor();
  6.  
  7. switch ($_SERVER['HTTP_HOST']) {
  8. case ROOT_LANDING_URL:
  9. $processor->processLandingRequest($_SERVER['REQUEST_URI']);
  10. break;
  11. case ROOT_APP_URL:
  12. $processor->processAppRequest($_SERVER['REQUEST_URI']);
  13. break;
  14. case ROOT_SHORT_URL:
  15. $processor->processShortRequest($_SERVER['REQUEST_URI']);
  16. break;
  17. default:
  18. header("Location:http://" . ROOT_LANDING_URL);
  19. break;
  20. }



config.php
  1. //Define DB params
  2. define("DB_HOST", "localhost");
  3. define("DB_USER", "xxx");
  4. define("DB_PASS", 'xxx');
  5. define("DB_NAME", "stronka");
  6.  
  7. //Define URL
  8. define("ROOT_LANDING_URL", "localhost");
  9. define("ROOT_APP_URL", "app.localhost");
  10. define("ROOT_SHORT_URL", "riy");
  11.  
  12. foreach (glob("app/*.php") as $filename) {
  13. include $filename;
  14. }
  15.  
  16. include("RequestProcessor.php");


RequestProcessor.php
  1. namespace Hajduk\Shortener;
  2.  
  3. class RequestProcessor
  4. {
  5. public function processShortRequest($request)
  6. {
  7. $shortener = new Shortener();
  8. $shortener->RedirectToDestinationUrl(
  9. '/',
  10. '',
  11. $request
  12. )
  13. );
  14. }
  15. public function processAppRequest($request)
  16. {
  17. $dashboard = new Dashboard($request);
  18. $dashboard->ProcessRequest();
  19. }
  20. public function processLandingRequest($request)
  21. {
  22. require("landing.view.php");
  23. }
  24. }


I wreszcie Dashboard.php który to ma wyświetlić dashboard.view.php ale wygląda na to że mi go nie wyświetla
  1. namespace Hajduk\Shortener;
  2.  
  3. class Dashboard
  4. {
  5. private $request;
  6. private $post;
  7. private $get;
  8. public function __construct($request)
  9. {
  10. $requestString = explode("?", $request);
  11. $this->request = empty($requestString) ? $request : $requestString[0];
  12. }
  13. public function processRequest()
  14. {
  15. if (!$this->request) {
  16. return;
  17. }
  18. $this->post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
  19. $this->get = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
  20. switch ($this->request) {
  21. case "/":
  22. $this->showDashboard();
  23. break;
  24. }
  25. }
  26.  
  27. private function showDashboard()
  28. {
  29. $clicks = 1020;
  30. $count = 100;
  31. require("app/views/dashboard.view.php");
  32. }
  33. }


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
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.09.2025 - 01:51