Laravel integration
Hi,
Been struggling to try and integrate ziggeo into Laravel 5.0
Trying to include/require Ziggeo.php file into a controller or include as a class etc. Get a ways and then it fails with ZiggeoException.php. Can't find the 'Exception' class. I'm not sure what to do.
Any ideas would be great. A pkg would be awesome. But I'd settle for help at this point
Thanks, tj
-
Hi Todd,
I have not had a chance to work with Laravel so far, however checking their website and few others, I think that this would help you accomplish what you want: http://laraveldaily.com/how-to-use-external-classes-and-php-files-in-laravel-controller/
In short it shows where to place the file and how to add the additional files (such as php files with functions, etc) which would then be loaded for you without using include/require statements, rather having Laravel load them for you.
Please do check it out and let us know how it goes, while I will also check if someone is a bit more familiar with Laravel in our team and could provide additional steps if needed :)
Bane
0 -
Yes that is the actual directions I was using. Going to keep working at it later today. See what I can figure out.
Ive included:
use Exceptions;
at the top of the ZiggeoExceptions.php file and now am getting a 404
ZiggeoException in ZiggeoConnect.php line 30: Not Found (404)
- in ZiggeoConnect.php line 30
- at ZiggeoConnect->assert_state('200', '404', false) in ZiggeoConnect.php line 38
0 -
Maybe this is related... create a wrapper for it?
http://stackoverflow.com/questions/15190772/using-a-non-laravel-package-on-laravel-4
0 -
Hi Todd,
Could you please try to change the Ziggeo SDK code to see what URL is it trying to connect to our servers over?
To do that, simply open the following file: ZiggeoConnect.php
After line 12 and before current 13 add this code:
echo 'url:"' . $this->application->config()->get("server_api_url") . "/v1" . $url . '"';
You should get value such as:
https://srvapi.ziggeo.com/v1/videos/
Based on what you have mentioned it seems that it is changing the URL to some other value which causes this and knowing more would allow us to see what should be done to resolve the same.Please do let us know how it goes.
0 -
Hi,
It echo'd out the url correctly (test video I'm using):
url:"https://srvapi.ziggeo.com/v1/videos/96d08f08eb96b7c855329a336e000f1b"
In laravel I used class mapping and put all files in the same Classes directory. Got rid of this (believed it was messing up the paths):
spl_autoload_register(function ($class) {
$fname = dirname(__FILE__) . "/classes/" . $class . '.php';
if (file_exists($fname))
include $fname;
});and then mapped it via composer dump-autoload
Checking the autoload_classmap.php file after generating it I see this added:
'Ziggeo' => $baseDir . '/app/Classes/Ziggeo.php',
'ZiggeoAuth' => $baseDir . '/app/Classes/ZiggeoAuth.php',
'ZiggeoAuthtokens' => $baseDir . '/app/Classes/ZiggeoAuthtokens.php',
'ZiggeoConfig' => $baseDir . '/app/Classes/ZiggeoConfig.php',
'ZiggeoConnect' => $baseDir . '/app/Classes/ZiggeoConnect.php',
'ZiggeoException' => $baseDir . '/app/Classes/ZiggeoException.php',
'ZiggeoStreams' => $baseDir . '/app/Classes/ZiggeoStreams.php',
'ZiggeoVideos' => $baseDir . '/app/Classes/ZiggeoVideos.php',But my error remains:
ZiggeoException in ZiggeoConnect.php line 30: Not Found (404)
0 -
Out of interest, I get the same error if I leave this in (adjusted the path since I put all the files at same level):
spl_autoload_register(function ($class) {
$fname = dirname(__FILE__) . "/" . $class . '.php';
if (file_exists($fname))
include $fname;
});0 -
Hi Todd,
Thank you for the additional info.
I am not familiar with Laravel, however I will try to set it up on my side and see if I can have it set up and if so I'll update you here with the steps I made.
* I do wish to mention that I am traveling at this time, so my connection is not quite as good and as such please do give me a bit of time to do this.
Could you also tell us what call are you making when you get the error - since you are loading a video I am just wondering if it might be working to some point and breaking at the next or if it fails on every load of the code.
0 -
That would be an awesome help
I sold my soul on how great this service can fit our needs so I have to figure it out :)
I'll post my controller when I get home in a bit
I was only making the connection and using the get method to fetch a vid or the image0 -
All that was in my controller was:
use Ziggeo;
$ziggeo = new Ziggeo('my 3 connection paramaters as in documentation);
$ziggeo->videos()->get('96d08f08eb96b7c855329a336e000f1b');this would produce the 404 from my controller
I'd get the same message if I left the 'use Ziggeo' in controller and place the rest in a view
0 -
Hi Todd,
Could you please try making the following changes:
Ziggeo.php file
add:
namespace app\Classes;
*If its path is /home/steeleau/steeleauto/backend/app/Classes/Ziggeo.php
and remove the spl_autoload_register() function (header and its body).
Now, move all of the Ziggeo SDK class files into a new folder (for example):
/home/steeleau/steeleauto/backend/app/Classes/ziggeo/
*Just the files that were originally in SDK in classes folder.
Once you do that make the changes to composer to auto load all of the files there.
composer.json file
add:
"autoload": {
"classmap": [
"database",
"app/Classes/ziggeo"
],
},In your controller, add the following instead of "use Ziggeo":
use app\Classes\Ziggeo;
Do let us know how it goes.
PS: I was not able to use Laravel out of the box, so I was not able to test the above out, however that is what it seems to be needed based on the check of Laravel docs.
Please do of course let us know how it goes.
Bane
0 -
Hi,
unfortunately exact same result. Have now tried class loading, installing, psr-4 loading and so on. I can't figure out what it is trying to 'find?' Anyway you can think to have it show what the url its even trying to go to would be?
I'm looking into hiring the guy who wrote the article you pointed out but not sure if that will happen.
ZiggeoException in ZiggeoConnect.php line 29: Not Found (404)
- in ZiggeoConnect.php line 29
- at ZiggeoConnect->assert_state('200', '404', false) in ZiggeoConnect.php line 37
- at ZiggeoConnect->get('/videos/96d08f08eb96b7c855329a336e000f1b', array(), '200') in ZiggeoConnect.php line 42
- at ZiggeoConnect->getJSON('/videos/96d08f08eb96b7c855329a336e000f1b') in ZiggeoVideos.php line 16
- at ZiggeoVideos->get('96d08f08eb96b7c855329a336e000f1b') in VideoController.php line 26
0 -
Or is there someway to skip that exception check so I can get passed it and see what is going on?
0 -
Hi Todd,
I see that you have placed the files into:
/home/steeleau/steeleauto/backend/app/Ziggeo/ziggeo/
I believe that the Ziggeo.php has this path:
/home/steeleau/steeleauto/backend/app/Ziggeo/Ziggeo.php
and the rest of the files are in the "ziggeo" folder:
/home/steeleau/steeleauto/backend/app/Ziggeo/ziggeo/
Now, for it, if I understood the Laravel documentation correctly, the namespace (in Ziggeo.php) would be:
namespace app\Ziggeo;
Then in composer.json file you would have:
"autoload": {
"classmap": [
"database",
"app/Ziggeo/ziggeo"
],
},Now in your controller (/home/steeleau/steeleauto/backend/app/Http/Controllers/VideoController.php) you would have:
use app\Ziggeo\Ziggeo;
I do want to mention that based on the error 404 it does seem that the files are loaded by Laravel and that they are in use, just that for some reason you are getting error 404.
Could you try to retrieve the response in your Laravel code from the same URL that you got through SDK (with pure PHP / Laravel code, without our SDK)?
This would tell us if the issue is with access to the same URL.
https://srvapi.ziggeo.com/v1/videos/96d08f08eb96b7c855329a336e000f1b
In regards to exception. You could try to comment out the line 37 of your ZiggeoConnect.php file.
This would make the get function look like this:
function get($url, $data = array(), $assert_state = ZiggeoException::HTTP_STATUS_OK) {
if (count($data) > 0)
$url .= '?' . http_build_query($data);
$curl = $this->curl($url);
$result = curl_exec($curl);
// $this->assert_state($assert_state, curl_getinfo($curl, CURLINFO_HTTP_CODE), $result);
return $result;
}This will return the result instead of 404 status.
Hope this helps.
Bane
0
Please sign in to leave a comment.
Comments
13 comments