Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Common Pages
  • Been reading lots of different code that has been shared and one thing I've noticed is a repeating of common functions that I thought would be defined in a common location. The function am thinking of is for a 404 page. I've noticed a lot of people have one in each class, is this really necessary? or is it something people are doing for some weird reason? I was trying to develop some common pages and put them into one class but now am wondering whether this is not possible or something? Can someone shed some light onto why people are doing this?
  • In general it's pointless having one in every class. 404's are triggered in FuelPHP by throwing a HttpNotFoundException, which is caught in your applications index.php, which then either loads your custom 404 controller, or shows the default not found message. There are situations where you would want something special in your controller, for example if the URI contains search arguments. You can then define routes for URI segments that meet the required criteria, and finish with a catch-all route for that controller that shows some error message and for example instructions on how to use that particular function. But I think its better to extend the HttpNotFoundException, and use a custom handle() method to deal with the exception.
  • Harro Verton wrote on Friday 28th of October 2011:
    In general it's pointless having one in every class. 404's are triggered in FuelPHP by throwing a HttpNotFoundException, which is caught in your applications index.php, which then either loads your custom 404 controller, or shows the default not found message. There are situations where you would want something special in your controller, for example if the URI contains search arguments. You can then define routes for URI segments that meet the required criteria, and finish with a catch-all route for that controller that shows some error message and for example instructions on how to use that particular function. But I think its better to extend the HttpNotFoundException, and use a custom handle() method to deal with the exception.

    Do you have any examples of these methods you speak of? Or is this all what you think and not really documented in any form just yet?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion