title: Best way to see if a view file (.ctp) exists in Cake PHP?
body: <p>I am using CakePHP 3, and would like to change the behaviour of the handy PagesController which comes with the installation. </p>
  
  <p>The current solution they use when trying to find and render a view file (.ctp) is using a try{} block, which is working well. 
  Actual code:  </p>
  
  <pre><code>try {
          $this-&gt;render(implode('/', $path));
  } catch (MissingTemplateException $e) {
  </code></pre>
  
  <p>But in my case the most common situation will be that the .ctp file <em>does not</em> exist. (If it does not exist, it will go on with a default view and try fetch content from database, but it is not my problem here.)</p>
  
  <p>In my modified version the most normal case will be that the MissingTemplaceException is thrown, which seem a bit overkill. 
  Why can I not simply check if the file exists? </p>
  
  <p>Am I thinking right here? And if I am, how do I check for the file's existence? </p>
  
  <hr>
  
  <p>After some fiddling around, I found the APP constant. This works: </p>
  
  <pre><code>$path = func_get_args();
  $file = APP.'Template'.DS.'Pages'.DS.implode('/', $path).'.ctp';
  if (file_exists($file))
  {
    // Render the file.
  }
  else
  {
    // Render some default file.
  }
  </code></pre>