Support the ongoing development of Laravel.io →
posted 10 years ago
IOC

Hi, I have service provier:

class TwitterServiceProvider extends ServiceProvider {
    public function register()
    {
        $this->app->bind('Libraries\Wrappers\SocialApi\Twitter', function() {
            return new CacheSocialApiDecorator(new Twitter());
        });
    }
}

How would I this inject into controller? My attempt is like this:

use Libraries\Wrappers\SocialApi\Twitter;

class TeamController extends BaseController {
   protected $twitterApi;
   public function __construct(Twitter $twitterApi)
   {
       $this->twitterApi = $twitterApi;
   }

}

What am I missing? What is best solution?

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.