Reputation: 1090
I'm trying to integrate a 3rd party library (this video site API: https://github.com/SproutVideo/sproutvideo-php ) with my Laravel site. But I think this is a generic question.
The video API instructs me to call it like so:
SproutVideo::$api_key = 'abcd1234';
or
$token = SproutVideo\UploadToken::create_upload_token();
I put these calls inside a function in one of my Laravel controllers. Unfortunately when this function is called, I get the following kind of error:
(for the first example call above)
FatalThrowableError
Class 'App\Http\Controllers\SproutVideo' not found
(or for the second:)
FatalThrowableError
Class 'App\Http\Controllers\SproutVideo\UploadToken' not found
(I think) I've included the Sproutvideo library at the top of the Controller file:
require '../vendor/autoload.php'; // Load SproutVideo API library
So how do I get Laravel to stop thinking the Sproutvideo API calls are Laravel controller calls, and just let them pass through to the Sproutvideo library?
Thanks
Upvotes: 0
Views: 228
Reputation: 2231
You have to import it at the top with
use (Path To Lib in vendor directory)
Then it's namespaced and you can use it. Otherwise use the fully qualified namspace directly in the code.
Although you import it via autoload (which really should happen not in the controller class itself when using Laravel btw *), you have to tell the controller class the namespace.
Upvotes: 1