2017 © Pedro Peláez
 

library laravel-shopify

An easier to use rocket-code/shopify for Shopify integration in Laravel applications

image

boaideas/laravel-shopify

An easier to use rocket-code/shopify for Shopify integration in Laravel applications

  • Tuesday, September 26, 2017
  • by amosmos
  • Repository
  • 3 Watchers
  • 2 Stars
  • 889 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 34 % Grown

The README.md

Easier Laravel integration for rocket-code/shopify

Latest Version on Packagist Software License StyleCI Total Downloads, (*1)

This packages allows for a better integration of rocket-code/shopify in Laravel applications., (*2)

Benefits

By using this package you get these added values:, (*3)

  • Auto discovery (Laravel 5.5 or higher) - no need to manually add any service provider
  • Configuration in env file
  • Allow the service to be used in dependency injection
  • Allow usage as real time facade (Laravel 5.4 or higher)

Installation

You can install the package via composer:, (*4)

composer require boaideas/laravel-shopify

If you're installing the package on Laravel 5.5 or higher, you're done (The package uses Laravel's auto package discovery)., (*5)

If you're using Laravel 5.4 or less, add the BOAIdeas\Shopify\ShopifyServiceProvider service provider to your providers array:, (*6)

// config/app.php

'providers' => [
    ...
    BOAIdeas\Shopify\ShopifyServiceProvider::class,
];

Configuration

Now, by default, the package will look for the following values in your .env file:, (*7)

// .env

SHOPIFY_KEY=YourAppApiKey
SHOPIFY_SECRET=YourAppSecret
SHOPIFY_DOMAIN=YourShopDomain (for private apps)
SHOPIFY_TOKEN=YourToken

If, for some reason, you want to change any of these settings, you can publish the config file with:, (*8)

php artisan vendor:publish --provider="BOAIdeas\Shopify\ShopifyServiceProvider"

This is the content of the published config file:, (*9)

// config/shopify.php

return [
    'api_key'       => env('SHOPIFY_KEY'),
    'api_secret'    => env('SHOPIFY_SECRET'),
    'shop_domain'   => env('SHOPIFY_DOMAIN'),
    'access_token'  => env('SHOPIFY_TOKEN'),
];

Usage

Once installed, you can use the service by either injecting it to your methods or as a real time facade, and then just use it regularly., (*10)

For more information about how to use the service, look at https://github.com/joshrps/laravel-shopify-API-wrapper., (*11)

Dependency Injection

Now you can simply type hint the service in your method's arguments. For better readabilty, we prefer to import the full class name with a use statement, and alias it to Shopify while we're at it., (*12)

use RocketCode\Shopify\API as Shopify;

Route::get('/', function (Shopify $shopify) {

    $call = $shopify->call(
    [
        'URL' => 'products.json',
        'METHOD' => 'GET',
        'DATA' => [
            'limit' => 5,
            'published_status' => 'any'
        ]
    ]);

});

Facade

Now you can use Laravel's on the fly facades feature to use the service "statically". We prefer to alias it to ShopifyAPI while we're at it., (*13)

use Facades\RocketCode\Shopify\API as ShopifyAPI;

Route::get('/', function () {

    $call = ShopifyAPI::call(
    [
        'URL' => 'products.json',
        'METHOD' => 'GET',
        'DATA' => [
            'limit' => 5,
            'published_status' => 'any'
        ]
    ]);

});

Credits

License

The MIT License (MIT). Please see License File for more information., (*14)

The Versions

26/09 2017

dev-master

9999999-dev https://github.com/amosmos/laravel-shopify

An easier to use rocket-code/shopify for Shopify integration in Laravel applications

  Sources   Download

MIT

The Requires

 

laravel api shopify boa ideas laravel-shopify

25/09 2017

v1.0.0

1.0.0.0 https://github.com/amosmos/laravel-shopify

An easier to use rocket-code/shopify for Shopify integration in Laravel applications

  Sources   Download

MIT

The Requires

 

laravel api shopify boa ideas laravel-shopify