joshrps / laravel-shopify-API-wrapper

Interface designed for Shopify apps created with Laravel
MIT License
93 stars 48 forks source link

Utilize Laravel's Session:: and Config:: facades #12

Closed kevinruscoe closed 8 years ago

kevinruscoe commented 9 years ago

I think a common way to use this library is the make 3 routes (an installer form, the installer redirect, and the callback).

Unfortunatly you need to pass the app()->make('shopifyAPI') on each call. Wouldn't it make more sense to store the Shopify API and KEY in a config that is automatically used on creating an instance? Also perhaps using Session:: to save the requested Shop Name and Token? That'll be a big push to do more things behind the scenes.

What are your thoughts?

joshrps commented 8 years ago

I think that's a valid point, but I don't want to lock users into one way of doing this. If you look at the examples in the readme, there's one where you may need to switch shops (for example, during a CRON job). I could probably add something to it that looks for a specific config and if it's available, it uses it, otherwise it requires you to do it yourself. I am incredibly hesitant to use Session by default.

Personally, I do use Config in order to set the data, all of my App::make() statements look like this:

$sh = App::make('ShopifyAPI', [
    'API_KEY' => Config::get('shopify.APP_API_KEY'),
    'API_SECRET' => Config::get('shopify.APP_API_SECRET'),
    'SHOP_DOMAIN' => $shop->getDomain(),
    'ACCESS_TOKEN' => $shop->getAccessToken()
]);

$shop is an instance of a small Shopify class I've written for personal use