Search code examples
phplaravelioc-containertumblr

Add library to laravel via composer


I have installed laravel via composer and Tumblr php library via composer as well. Now when I say:

var_dump(App::make('Tumblr'));

I get and exception that Class Tumblr does not exist. How should I make this class visible to laravel? I use laravel 4


Solution

  • If you are using this library (https://github.com/tumblr/tumblr.php/), you will need to use namespaces or set an alias in the app.php config file.

    Using namespaces:

    $client = new Tumblr\API\Client($consumerKey, $consumerSecret);
    $client->setToken($token, $tokenSecret);
    

    And you can set an alias in the alias array:

    'Tumblr' => 'Tumblr\API\Client'
    
    $tumblr = new Tumblr;
    

    And if you wanna you the IoC container, you can set a bind:

    App::bind('Tumblr', 'Tumblr\API\Client');
    
    $tumblr = App::make('Tumblr');