Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4, Composer and hybridauth - How to load additional providers

I'm using Laravel 4 and have loaded hybridauth via composer and got it working just fine with Facebook and Twitter. Now i'm trying to get it working with Steam, which is listed as an additional provider, however I keep getting the following error:

require_once(vendor/hybridauth/hybridauth/hybridauth/Hybrid/Providers/Steam.php) [function.require-once]: failed to open stream: No such file or directory

Clearly it's looking in the wrong place, the actual class resides in this location:

vendor/hybridauth/hybridauth/additional-providers/hybridauth-steam/Providers/Steam.php

There's very little documentation that I can find on this, my only guess is that the author of hybridauth only offered these additional providers as optional extras and expects you to move the location of the class to the proper place, however with composer this isn't the way to do things and will cause problems anytime I run composer update.

I can't find anyone having a similar problem via Google, which seems strange so i'm worried i'm missing obvious. Is there a way to use the additional providers, to have them autoload, while using hybridauth with Composer?

The only solution I can think to do is to manually include the correct file before it tries to autoload. I don't mind doing that, but i'm assuming there must be a proper way to do this otherwise using Composer with Hybridauth is fairly useless.

like image 591
John Mellor Avatar asked Sep 03 '13 12:09

John Mellor


1 Answers

I had this problem with Instagram and was able to use the wrapper syntax, which is documented here http://hybridauth.sourceforge.net/userguide/tuts/specific-provider-wrapper.html

The code below got the Instagram adapter working for me.

           "Instagram" => array ( 
                "enabled" => true,
                "keys"    => array ( 
                    "id" => xxxx, 
                    "secret" => xxxx,
                ),
                "wrapper" => array(
                    'class'=>'Hybrid_Providers_Instagram',
                    'path' => $_SERVER['DOCUMENT_ROOT'].'/../vendor/hybridauth/hybridauth/additional-providers/hybridauth-instagram/Providers/Instagram.php'
                )
            ),

If you read the source at hybridauth/Hybrid/Provider_Adapter.php line 69, you'll see it checks for this before doing require_once with the standard path.

like image 61
Tim Avatar answered Sep 24 '22 00:09

Tim