Quantcast
Viewing latest article 4
Browse Latest Browse All 24

By: Alex Gervasio

Glad to hear that. Now, about your questions:
1) “If I set up multiple controllers to handle different tasks, do I now need to specify them in the index.php using:
$request = new Request( … );
$response = new Response();”
Yes, that portion of the snippet is correct, but in addition you’ll need to add to the router a new route per controller you may want call.
2) “Is there an automated way for index.php to handle multiple urls?” Honestly, I don’t know exactly what you mean with this. If with multiple urls you mean calling multiple controllers when a single request is dispatched, well that sounds pretty much like an HMVC implementation, which personally I’m not a big fan of it. Handling several MVC triads doesn’t make much sense, at least to my view. In fact, I’m much more comfortable working with a classic MVC schema, coupled to a nice service layer.
3) “Also what about other aspects of the URI such as example.com/test/this-is-an-example … what would be an example of where you would specify what the 3rd parameter of the uri is parsed…like to view a specific article…”
Please notice each action controller injects an instance of the Request class. So, it should be pretty easy to extract from it the param(s) you need, for instance, for handling different resources, like articles and the like. Thanks :)


Viewing latest article 4
Browse Latest Browse All 24

Trending Articles