4

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.

David A McInnis
  • 1,201
  • 12
  • 26

1 Answers1

8

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;
Lindsey D
  • 23,974
  • 5
  • 53
  • 110