Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Best way to check if view file exists?
  • What do you use to check if the view exists or not?
  • I don't think there is a particular mechanism built in for this. But you could do something like this:
    if (file_exists(APPPATH . 'views/'. $viewfile) === true) {
        $view = View::forge($viewfile);
    } else {
        // view doesn't exist
    }
    
  • Depends. If it's always in your app folder bproctors way will do fine. If the View should exist but might not be found in the app or any package, I tend to just create it and see if it fails. When if fails I catch the exception and make it fallback to a default or error view.

Howdy, Stranger!

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

In this Discussion