Laravel Shopify
  • 🛍️Laravel Shopify
  • Getting Started
    • 👋Installation
  • Usage
    • Prerequisites
    • Intializing the client
    • Making Requests
      • Pagination
      • GraphQL
    • Custom Requests
    • Custom Error Handling
    • Available Methods
      • Supported Method
    • Webhooks
Powered by GitBook
On this page
  • Resolve from the service container
  • Resolve using the factory
  • Resolve using dependency injection
  1. Usage

Intializing the client

You can initialize the client in different ways to start communicating with the Shopify API.

use Pactode\Shopify\Shopify;

$shopify = new Shopify(
    env('SHOPIFY_ACCESS_TOKEN'),
    env('SHOPIFY_DOMAIN'),
    env('SHOPIFY_API_VERSION')
);

Resolve from the service container

Using class:

use Pactode\Shopify\Shopify;

$shopify = app(Shopify::class);

Using alias:

$shopify = app('shopify');

Resolve using the factory

$shopify = \Pactode\Shopify\Factory::fromConfig();

Resolve using dependency injection

You may also inject the Shopify class into a method of a Controller:

use Illuminate\Http\Request;
use Pactode\Shopify\Shopify;

class ProductController{
    public function index(Request $request, Shopify $shopify)
    {
        // do something here    
    }
}

By default it will look for credentials in your config, when resolving the client.

PreviousPrerequisitesNextMaking Requests

Last updated 1 year ago