title: How to check the existence of a namespace in php
body: <p>I have a <strong>php library</strong> <a href="https://github.com/tedivm/Fetch">https://github.com/tedivm/Fetch</a> and it uses Fetch namespace and I would like to check its existence in my script.</p>
  
  <p><em>My script code:</em></p>
  
  <pre><code>// Load Fetch
  spl_autoload_register(function ($class) {
      $file = __DIR__ . '/vendor/' . strtr($class, '\\', '/') . '.php';
      if (file_exists($file)) {
          require $file;
  
          return true;
      }
  });
  
  if (!class_exists('\\Fetch')) {
    exit('Failed to load the library: Fetch');
  }
  $mail = new \Fetch\Server($server, $port);
  </code></pre>
  
  <p>but this message is always displayed. But the library is fully working.</p>
  
  <p>Thanks in advance for any help!</p>