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.

1 Answer 1

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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.