PHPackages                             robwittman/shopify-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. robwittman/shopify-php-sdk

ActiveLibrary[API Development](/categories/api)

robwittman/shopify-php-sdk
==========================

PHP SDK for Shopify API

v2.4.2(5y ago)7098.9k—8.7%40[15 issues](https://github.com/robwittman/shopify-php-sdk/issues)[7 PRs](https://github.com/robwittman/shopify-php-sdk/pulls)1MITPHPPHP &gt;=7.2CI failing

Since May 10Pushed 1y ago7 watchersCompare

[ Source](https://github.com/robwittman/shopify-php-sdk)[ Packagist](https://packagist.org/packages/robwittman/shopify-php-sdk)[ Docs](http://github.com/robwittman/shopify-php-sdk)[ RSS](/packages/robwittman-shopify-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (28)Used By (1)

[![Build Status](https://camo.githubusercontent.com/f528a5771249e55522428d16d75d6e2eead8e152ae5e6b4f65d2bc2afe2261c3/68747470733a2f2f7472617669732d63692e6f72672f726f62776974746d616e2f73686f706966792d7068702d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/robwittman/shopify-php-sdk)

Shopify PHP SDK
===============

[](#shopify-php-sdk)

This SDK was created to enable rapid efficient development using Shopify's API.

Installation
------------

[](#installation)

Easily install this package with composer

```
composer require robwittman/shopify-php-sdk
```

Before you can start using this SDK, you have to create a [Shopify Application](https://partners.shopify.com/)You can now use the API key and secret to generate access tokens, which can then access a stores data

Initialization
--------------

[](#initialization)

To initialize the Api Client:

```
$client = new Shopify\Api(array(
    'api_key' => '',
    'api_secret' => '',
    'myshopify_domain' => 'store.myshopify.com',
    'access_token' => ''
));
```

If you are using a Private App for use on an individual store:

```
$client = new Shopify\PrivateApi(array(
    'api_key' => '',
    'password' => '',
    'shared_secret' => '',
    'myshopify_domain' => '.myshopify.com'
));
```

Once the client is initialized, you can then create a service, and use it to communicate with the api

### Reading

[](#reading)

```
$service = new Shopify\Service\ProductService($client);
$service->all(); #Fetch all products, with optional params
$service->get($productId); # Get a single product
$service->count(); # Count the resources
```

### Creating

[](#creating)

```
$service = new Shopify\Service\ProductService($client);
$product = new Shopify\Object\Product();
# Set some product fields
$product->title = 'Test Product';
$product->vendor = 'Printer';

$service->create($product);
```

### Updating

[](#updating)

```
$service = new Shopify\Service\ProductService($client);
$product = $service->get($productId);
# Set some product fields
$product->title = 'Test Product';
$product->vendor = 'Printer';

$service->update($product);
```

### Deleting

[](#deleting)

```
$service = new Shopify\Service\ProductService($client);
$service->delete($productId);
```

### GraphQL

[](#graphql)

#### Query

[](#query)

```
$service = new Shopify\Service\GraphQLService($client);
$service->graph(
  '{
    products(query: "created_at:
