Jump to content

Dispatching Requests to Multiple Controllers Problem


seamoh

Recommended Posts

Hello All:

in Killer php Advance php cc (17 videos) in Dispatching Requests to Multiple Controllers . John lebensold teach the follwing switch :

switch($uri)

{

case "/";

case "index";

$controller = new Controllers\IndexController();

break;

case "/test":

$controller = new Controllers\TestController();

 

break;

 

}

 

But I encounter a problem , when I tes http://killerphp or http://killerphp/test , the browser shows nothing , because it doesn't know to call dispatch() method in each controller , then I try to call each controller dispatch method as below :

switch($uri)

{

case "/";

case "index";

$controller = new Controllers\IndexController();

$controller->dispatch($uri);

break;

case "/test":

$controller = new Controllers\TestController();

$controller->dispatch($uri);

break;

 

}

then it works . and the controller works . Mr Jon Lebensold use the first switch .would you please discuss what is the problem

Sincerely yours

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...