title: slim framework Method notFound is not a valid method
body: <p>I am creating an api using the Slim framework for the first time.</p>
  
  <p>I want to return a specific response if url not found.</p>
  
  <p>I use <code>notFound</code> function of Slim framework as follows:</p>
  
  <pre><code>$app-&gt;notFound(function () use ($app) {
      $res = array("msg"=&gt;"page not found");
      $response-&gt;getBody()-&gt;write(json_encode($res));
      return $response;
  });
  </code></pre>
  
  <p>but when I add this line of code in my php page it shows me following error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'BadMethodCallException' with message 'Method notFound is not a valid method' in C:\wamp\www\api\vendor\slim\slim\Slim\App.php on line 129</p>
    
    <p>BadMethodCallException: Method notFound is not a valid method in C:\wamp\www\api\vendor\slim\slim\Slim\App.php on line 129</p>
  </blockquote>