Anahkiasen / flickering

A modern PHP interface for the Flickr API
50 stars 20 forks source link

Dependency Injection with Laravel #5

Open bkintanar opened 11 years ago

bkintanar commented 11 years ago

I have a detailed my issue here: http://forums.laravel.io/viewtopic.php?pid=58597#p58597

Anahkiasen commented 11 years ago

It seems Laravel is resolving Flickering\Flickering to Flickering\Facades\Flickering, is there any App::bind or alias set that that way ?

bkintanar commented 11 years ago

Well I've followed the tutorial here: http://www.mackhankins.com/blog/laravel/recent-flickr-photos-with-flickr-api-and-laravel

and it says to put the following in the app/config/app.php file

'aliases' => array( 'Flickering' => 'Flickering\Facades\Flickering' )

Anahkiasen commented 11 years ago

Yeah but that's if you're going to use the Flickering facade directly, if you're going to use the class directly by injection, you don't need it.

bkintanar commented 11 years ago

So I've tried removing the alias and what I'm getting now is

Call to undefined method Illuminate\Support\Facades\Config::get()

my code is

class PhotographyController extends BaseController {

    public function __construct(Flickering\Flickering $flickering)
    {
        $this->flickering = $flickering;

        $this->flickering->handshake(Config::get('flickr.app_key'), Config::get('flickr.api_secret'));
    }
}
Anahkiasen commented 11 years ago

Can you show me the full code of the controller ?

bkintanar commented 11 years ago

I pasted it here: http://paste.laravel.com/ZHY