Answers.Body: <p>Through the magic of PHP namespacing, all plugins fall under the <code>Craft</code> parent class by default.</p>
  
  <p>Since you're accessing a library outside of the <code>Craft</code> scope, you'll need to prepend a backslash to your library's class name:</p>
  
  <pre><code>$app = new \fSDK;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-06T22:05:42.560Z
Answers.LastActivityDate: 2014-09-06T22:12:42.910Z
Answers.LastEditDate: 2014-09-06T22:12:42.910Z
Answers.UserDisplayName: Lindsey D
Body: <p>I am trying to instantiate a class from a third-party library from within a controller. Probably not the best place to do this but just testing.</p>
  
  <pre><code>require(craft()-&gt;path-&gt;getPluginsPath().'myplugin/vendor/ifpk/src/fsdk.php');
  
  $app = new fSDK;
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>Fatal error: Class 'Craft\fSDK' not found in /var/www/.../controllers/MyPluginController.php on line 57
  </code></pre>
  
  <p>Not sure where to go with this next.</p>
  
Tags: <plugin-development>
Title: Registering a class library within a plugin
ThreadText: # Registering a class library within a plugin
  
  (Asked by: username_0 on 2014-09-06)
  
  I am trying to instantiate a class from a third-party library from within a controller. Probably not the best place to do this but just testing.
  
  ```
  require(craft()->path->getPluginsPath().'myplugin/vendor/ifpk/src/fsdk.php');
  
  $app = new fSDK;
  
  ```
  
  I get the following error
  
  ```
  Fatal error: Class 'Craft\fSDK' not found in /var/www/.../controllers/MyPluginController.php on line 57
  
  ```
  
  Not sure where to go with this next.
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-09-06. Score: 8 | Accepted answer
  
  Through the magic of PHP namespacing, all plugins fall under the `Craft` parent class by default.
  
  Since you're accessing a library outside of the `Craft` scope, you'll need to prepend a backslash to your library's class name:
  
  ```
  $app = new \fSDK;
  
  ```
  
  
  ---
  
  