PHPackages                             roemerb/php-shopify - 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. roemerb/php-shopify

ActiveLibrary[API Development](/categories/api)

roemerb/php-shopify
===================

PHP SDK for Shopify API

v1.0.3(7y ago)0468Apache-2.0PHPPHP &gt;=5.6

Since Aug 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Roemerb/php-shopify)[ Packagist](https://packagist.org/packages/roemerb/php-shopify)[ Docs](https://github.com/phpclassic/php-shopify)[ RSS](/packages/roemerb-php-shopify/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (8)Used By (0)

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

[](#php-shopify-sdk)

[![Build Status](https://camo.githubusercontent.com/d987d76a954618e7fc933a0fed6053cd91474faffcaeeb2f3c73ce97295d5a2d/68747470733a2f2f7472617669732d63692e6f72672f706870636c61737369632f7068702d73686f706966792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phpclassic/php-shopify) [![Total Downloads](https://camo.githubusercontent.com/edeab8fd2b12ce3431ed2535111ffd68f8b351dcb07b29e4f25f4770f9de4905/68747470733a2f2f706f7365722e707567782e6f72672f706870636c61737369632f7068702d73686f706966792f646f776e6c6f616473)](https://packagist.org/packages/phpclassic/php-shopify) [![Latest Stable Version](https://camo.githubusercontent.com/519f6a914e281712d342e442574974e3f039aba1e68c805598d12f83b78b56d9/68747470733a2f2f706f7365722e707567782e6f72672f706870636c61737369632f7068702d73686f706966792f762f737461626c65)](https://packagist.org/packages/phpclassic/php-shopify) [![Latest Unstable Version](https://camo.githubusercontent.com/7503233a5bd452461282ebdb95b870d12ff04f267f427c03d28e7a4bd9dd9f1e/68747470733a2f2f706f7365722e707567782e6f72672f706870636c61737369632f7068702d73686f706966792f762f756e737461626c65)](https://packagist.org/packages/phpclassic/php-shopify) [![License](https://camo.githubusercontent.com/d35f7a4b0ca2cd4787071c922792e37677aeaa17de562a405d8a50e7126c6674/68747470733a2f2f706f7365722e707567782e6f72672f706870636c61737369632f7068702d73686f706966792f6c6963656e7365)](https://packagist.org/packages/phpclassic/php-shopify)

PHPShopify is a simple SDK implementation of Shopify API. It helps accessing the API in an object oriented way.

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

[](#installation)

Install with Composer

```
composer require phpclassic/php-shopify
```

### Requirements

[](#requirements)

PHPShopify uses curl extension for handling http calls. So you need to have the curl extension installed and enabled with PHP.

> However if you prefer to use any other available package library for handling HTTP calls, you can easily do so by modifying 1 line in each of the `get()`, `post()`, `put()`, `delete()` methods in `PHPShopify\HttpRequestJson` class.

Usage
-----

[](#usage)

You can use PHPShopify in a pretty simple object oriented way.

#### Configure ShopifySDK

[](#configure-shopifysdk)

If you are using your own private API, provide the ApiKey and Password.

```
$config = array(
    'ShopUrl' => 'yourshop.myshopify.com',
    'ApiKey' => '***YOUR-PRIVATE-API-KEY***',
    'Password' => '***YOUR-PRIVATE-API-PASSWORD***',
);

PHPShopify\ShopifySDK::config($config);
```

For Third party apps, use the permanent access token.

```
$config = array(
    'ShopUrl' => 'yourshop.myshopify.com',
    'AccessToken' => '***ACCESS-TOKEN-FOR-THIRD-PARTY-APP***',
);

PHPShopify\ShopifySDK::config($config);
```

##### How to get the permanent access token for a shop?

[](#how-to-get-the-permanent-access-token-for-a-shop)

There is a AuthHelper class to help you getting the permanent access token from the shop using oAuth.

1. First, you need to configure the SDK with additional parameter SharedSecret

```
$config = array(
    'ShopUrl' => 'yourshop.myshopify.com',
    'ApiKey' => '***YOUR-PRIVATE-API-KEY***',
    'SharedSecret' => '***YOUR-SHARED-SECRET***',
);

PHPShopify\ShopifySDK::config($config);
```

2. Create the authentication request

> The redirect url must be white listed from your app admin as one of **Application Redirect URLs**.

```
//your_authorize_url.php
$scopes = 'read_products,write_products,read_script_tags,write_script_tags';
//This is also valid
//$scopes = array('read_products','write_products','read_script_tags', 'write_script_tags');
$redirectUrl = 'https://yourappurl.com/your_redirect_url.php';

\PHPShopify\AuthHelper::createAuthRequest($scopes, $redirectUrl);
```

3. Get the access token when redirected back to the `$redirectUrl` after app authorization.

```
//your_redirect_url.php
PHPShopify\ShopifySDK::config($config);
$accessToken = \PHPShopify\AuthHelper::getAccessToken();
//Now store it in database or somewhere else
```

> You can use the same page for creating the request and getting the access token (redirect url). In that case just skip the 2nd parameter `$redirectUrl` while calling `createAuthRequest()` method. The AuthHelper class will do the rest for you.

```
//your_authorize_and_redirect_url.php
PHPShopify\ShopifySDK::config($config);
$accessToken = \PHPShopify\AuthHelper::createAuthRequest($scopes);
//Now store it in database or somewhere else
```

#### Get the ShopifySDK Object

[](#get-the-shopifysdk-object)

```
$shopify = new PHPShopify\ShopifySDK;
```

You can provide the configuration as a parameter while instantiating the object (if you didn't configure already by calling `config()` method)

```
$shopify = new PHPShopify\ShopifySDK($config);
```

##### Now you can do `get()`, `post()`, `put()`, `delete()` calling the resources in the object oriented way. All resources are named as same as it is named in shopify API reference. (See the resource map below.)

[](#now-you-can-do-get-post-put-delete-calling-the-resources-in-the-object-oriented-way-all-resources-are-named-as-same-as-it-is-named-in-shopify-api-reference-see-the-resource-map-below)

> All the requests returns an array (which can be a single resource array or an array of multiple resources) if succeeded. When no result is expected (for example a DELETE request), an empty array will be returned.

- Get all product list (GET request)

```
$products = $shopify->Product->get();
```

- Get any specific product with ID (GET request)

```
$productID = 23564666666;
$product = $shopify->Product($productID)->get();
```

You can also filter the results by using the url parameters (as specified by Shopify API Reference for each specific resource).

- For example get the list of cancelled orders after a specified date and time (and `fields` specifies the data columns for each row to be rendered) :

```
$params = array(
    'status' => 'cancelled',
    'created_at_min' => '2016-06-25T16:15:47-04:00',
    'fields' => 'id,line_items,name,total_price'
);

$orders = $shopify->Order->get($params);
```

- Create a new order (POST Request)

```
$order = array (
    "email" => "foo@example.com",
    "fulfillment_status" => "unfulfilled",
    "line_items" => [
      [
          "variant_id" => 27535413959,
          "quantity" => 5
      ]
    ]
);

$shopify->Order->post($order);
```

- Update an order (PUT Request)

```
$updateInfo = array (
    "fulfillment_status" => "fulfilled",
);

$shopify->Order($orderID)->put($updateInfo);
```

- Remove a Webhook (DELETE request)

```
$webHookID = 453487303;

$shopify->Webhook($webHookID)->delete());
```

### The child resources can be used in a nested way.

[](#the-child-resources-can-be-used-in-a-nested-way)

> You must provide the ID of the parent resource when trying to get any child resource

- For example, get the images of a product (GET request)

```
$productID = 23564666666;
$productImages = $shopify->Product($productID)->Image->get();
```

- Add a new address for a customer (POST Request)

```
$address = array(
    "address1" => "129 Oak St",
    "city" => "Ottawa",
    "province" => "ON",
    "phone" => "555-1212",
    "zip" => "123 ABC",
    "last_name" => "Lastnameson",
    "first_name" => "Mother",
    "country" => "CA",
);

$customerID = 4425749127;

$shopify->Customer($customerID)->Address->post($address);
```

- Create a fulfillment event (POST request)

```
$fulfillmentEvent = array(
    "status" => "in_transit"
);

$shopify->Order($orderID)->Fulfillment($fulfillmentID)->Event->post($fulfillmentEvent);
```

- Update a Blog article (PUT request)

```
$blogID = 23564666666;
$articleID = 125336666;
$updateArtilceInfo = array(
    "title" => "My new Title",
    "author" => "Your name",
    "tags" => "Tags, Will Be, Updated",
    "body_html" => "Look, I can even update through a web service.",
);
$shopify->Blog($blogID)->Article($articleID)->put($updateArtilceInfo);
```

- Delete any specific article from a specific blog (DELETE request)

```
$blogArticle = $shopify->Blog($blogID)->Article($articleID)->delete();
```

### Resource Mapping

[](#resource-mapping)

Some resources are available directly, some resources are only available through parent resources and a few resources can be accessed both ways. It is recommended that you see the details in the related Shopify API Reference page about each resource. Each resource name here is linked to related Shopify API Reference page.

> Use the resources only by listed resource map. Trying to get a resource directly which is only available through parent resource may end up with errors.

- [AbandonedCheckout](https://help.shopify.com/api/reference/abandoned_checkouts)
- [ApplicationCharge](https://help.shopify.com/api/reference/applicationcharge)
- [Blog](https://help.shopify.com/api/reference/blog/)
- Blog -&gt; [Article](https://help.shopify.com/api/reference/article/)
- Blog -&gt; Article -&gt; [Event](https://help.shopify.com/api/reference/event/)
- Blog -&gt; Article -&gt; [Metafield](https://help.shopify.com/api/reference/metafield)
- Blog -&gt; [Event](https://help.shopify.com/api/reference/event/)
- Blog -&gt; [Metafield](https://help.shopify.com/api/reference/metafield)
- [CarrierService](https://help.shopify.com/api/reference/carrierservice/)
- [Collect](https://help.shopify.com/api/reference/collect/)
- [Comment](https://help.shopify.com/api/reference/comment/)
- Comment -&gt; [Event](https://help.shopify.com/api/reference/event/)
- [Country](https://help.shopify.com/api/reference/country/)
- Country -&gt; [Province](https://help.shopify.com/api/reference/province/)
- CustomCollection
- CustomCollection -&gt; [Event](https://help.shopify.com/api/reference/event/)
- CustomCollection -&gt; [Metafield](https://help.shopify.com/api/reference/metafield)
- [Customer](https://help.shopify.com/api/reference/customer/)
- Customer -&gt; [Address](https://help.shopify.com/api/reference/customeraddress/)
- Customer -&gt; [Metafield](https://help.shopify.com/api/reference/metafield)
- [CustomerSavedSearch](https://help.shopify.com/api/reference/customersavedsearch/)
- CustomerSavedSearch -&gt; [Customer](https://help.shopify.com/api/reference/customer/)
- [Discount](https://help.shopify.com/api/reference/discount) *(Shopify Plus Only)*
- [Event](https://help.shopify.com/api/reference/event/)
- [FulfillmentService](https://help.shopify.com/api/reference/fulfillmentservice)
- [GiftCard](https://help.shopify.com/api/reference/gift_card) *(Shopify Plus Only)*
- [InventoryItem](https://help.shopify.com/api/reference/inventoryitem)
- [InventoryLevel](https://help.shopify.com/api/reference/inventorylevel)
- [Location](https://help.shopify.com/api/reference/location/) *(read only)*
- [Metafield](https://help.shopify.com/api/reference/metafield)
- [Multipass](https://help.shopify.com/api/reference/multipass) *(Shopify Plus Only, API not available yet)*
- [Order](https://help.shopify.com/api/reference/order)
- Order -&gt; [Fulfillment](https://help.shopify.com/api/reference/fulfillment)
- Order -&gt; Fulfillment -&gt; [Event](https://help.shopify.com/api/reference/fulfillmentevent)
- Order -&gt; [Risk](https://help.shopify.com/api/reference/order_risks)
- Order -&gt; [Refund](https://help.shopify.com/api/reference/refund)
- Order -&gt; [Transaction](https://help.shopify.com/api/reference/transaction)
- Order -&gt; [Event](https://help.shopify.com/api/reference/event/)
- Order -&gt; [Metafield](https://help.shopify.com/api/reference/metafield)
- [Page](https://help.shopify.com/api/reference/page)
- Page -&gt; [Event](https://help.shopify.com/api/reference/event/)
- Page -&gt; [Metafield](https://help.shopify.com/api/reference/metafield)
- [Policy](https://help.shopify.com/api/reference/policy) *(read only)*
- [Product](https://help.shopify.com/api/reference/product)
- Product -&gt; [Image](https://help.shopify.com/api/reference/product_image)
- Product -&gt; [Variant](https://help.shopify.com/api/reference/product_variant)
- Product -&gt; Variant -&gt; [Metafield](https://help.shopify.com/api/reference/metafield)
- Product -&gt; [Event](https://help.shopify.com/api/reference/event/)
- Product -&gt; [Metafield](https://help.shopify.com/api/reference/metafield)
- [ProductListing](https://help.shopify.com/api/reference/sales_channels/productlisting)
- [ProductVariant](https://help.shopify.com/api/reference/product_variant)
- ProductVariant -&gt; [Metafield](https://help.shopify.com/api/reference/metafield)
- [RecurringApplicationCharge](https://help.shopify.com/api/reference/recurringapplicationcharge)
- RecurringApplicationCharge -&gt; [UsageCharge](https://help.shopify.com/api/reference/usagecharge)
- [Redirect](https://help.shopify.com/api/reference/redirect)
- [ScriptTag](https://help.shopify.com/api/reference/scripttag)
- [ShippingZone](https://help.shopify.com/api/reference/shipping_zone) *(read only)*
- [Shop](https://help.shopify.com/api/reference/shop) *(read only)*
- [SmartCollection](https://help.shopify.com/api/reference/smartcollection)
- SmartCollection -&gt; [Event](https://help.shopify.com/api/reference/event/)
- [Theme](https://help.shopify.com/api/reference/theme)
- Theme -&gt; [Asset](https://help.shopify.com/api/reference/asset/)
- [User](https://help.shopify.com/api/reference/user) *(read only, Shopify Plus Only)*
- [Webhook](https://help.shopify.com/api/reference/webhook)

### Custom Actions

[](#custom-actions)

There are several action methods which can be called without calling the `get()`, `post()`, `put()`, `delete()` methods directly, but eventually results in a custom call to one of those methods.

- For example, get count of total projects

```
$productCount = $shopify->Product->count();
```

- Make an address default for the customer.

```
$shopify->Customer($customerID)->Address($addressID)->makeDefault();
```

- Search for customers with keyword "Bob" living in country "United States".

```
$shopify->Customer->search("Bob country:United States");
```

#### Custom Actions List

[](#custom-actions-list)

The custom methods are specific to some resources which may not be available for other resources. It is recommended that you see the details in the related Shopify API Reference page about each action. We will just list the available actions here with some brief info. each action name is linked to an example in Shopify API Reference which has more details information.

- (Any resource type except *ApplicationCharge, CarrierService, FulfillmentService, Location, Policy, RecurringApplicationCharge, ShippingZone, Shop, Theme*) -&gt;

    - [count()](https://help.shopify.com/api/reference/product#count)Get a count of all the resources. Unlike all other actions, this function returns an integer value.
- Comment -&gt;

    - [markSpam()](https://help.shopify.com/api/reference/comment#spam)Mark a Comment as spam
    - [markNotSpam()](https://help.shopify.com/api/reference/comment#not_spam)Mark a Comment as not spam
    - [approve()](https://help.shopify.com/api/reference/comment#approve)Approve a Comment
    - [remove()](https://help.shopify.com/api/reference/comment#remove)Remove a Comment
    - [restore()](https://help.shopify.com/api/reference/comment#restore)Restore a Comment
- Customer -&gt;

    - [search()](https://help.shopify.com/api/reference/customer#search)Search for customers matching supplied query
- Customer -&gt; Address -&gt;

    - [makeDefault()](https://help.shopify.com/api/reference/customeraddress#default)Sets the address as default for the customer
    - [set($params)](https://help.shopify.com/api/reference/customeraddress#set)Perform bulk operations against a number of addresses
- Discount -&gt;

    - enable()Enable a discount
    - disable()Disable a discount
- Fulfillment -&gt;

    - [complete()](https://help.shopify.com/api/reference/fulfillment#complete)Complete a fulfillment
    - [open()](https://help.shopify.com/api/reference/fulfillment#open)Open a pending fulfillment
    - [cancel()](https://help.shopify.com/api/reference/fulfillment#cancel)Cancel a fulfillment
- GiftCard -&gt;

    - [disable()](https://help.shopify.com/api/reference/gift_card#disable)Disable a gift card.
    - [search()](https://help.shopify.com/api/reference/gift_card#search)Search for gift cards matching supplied query
- InventoryLevel -&gt;

    - [adjust($data)](https://help.shopify.com/api/reference/inventorylevel#adjust)Adjust inventory level.
    - [connect($data)](https://help.shopify.com/api/reference/inventorylevel#connect)Connect an inventory item to a location.
    - [set($data)](https://help.shopify.com/api/reference/inventorylevel#set)Set an inventory level for a single inventory item within a location.
- Order -&gt;

    - [close()](https://help.shopify.com/api/reference/order#close)Close an Order
    - [open()](https://help.shopify.com/api/reference/order#open)Re-open a closed Order
    - [cancel($data)](https://help.shopify.com/api/reference/order#cancel)Cancel an Order
- Order -&gt; Refund -&gt;

    - [calculate()](https://help.shopify.com/api/reference/refund#calculate)Calculate a Refund.
- ProductListing -&gt;

    - [productIds()](https://help.shopify.com/api/reference/sales_channels/productlisting#product_ids)Retrieve product\_ids that are published to your app.
- RecurringApplicationCharge -&gt;

    - [activate()](https://help.shopify.com/api/reference/recurringapplicationcharge#activate)Activate a recurring application charge
    - [customize($data)](https://help.shopify.com/api/reference/recurringapplicationcharge#customize)Customize a recurring application charge
- SmartCollection -&gt;

    - [sortOrder($params)](https://help.shopify.com/api/reference/smartcollection#order)Set the ordering type and/or the manual order of products in a smart collection
- User -&gt;

    - [current()](https://help.shopify.com/api/reference/user#current)Get the current logged-in user

Reference
---------

[](#reference)

- [Shopify API Reference](https://help.shopify.com/api/reference/)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 88.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~114 days

Recently: every ~169 days

Total

7

Last Release

2870d ago

PHP version history (2 changes)1.0.0-alphaPHP &gt;=5.4

v1.0.0PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/cef747ee5406a851b87106d864e523d5412a4fb8e713f78faf3803186633109f?d=identicon)[complexity](/maintainers/complexity)

---

Top Contributors

[![tareqtms](https://avatars.githubusercontent.com/u/5279389?v=4)](https://github.com/tareqtms "tareqtms (70 commits)")[![alozytskyy](https://avatars.githubusercontent.com/u/42665348?v=4)](https://github.com/alozytskyy "alozytskyy (2 commits)")[![Roemerb](https://avatars.githubusercontent.com/u/4710404?v=4)](https://github.com/Roemerb "Roemerb (2 commits)")[![Gnilya](https://avatars.githubusercontent.com/u/2853725?v=4)](https://github.com/Gnilya "Gnilya (1 commits)")[![ymhuang0808](https://avatars.githubusercontent.com/u/2720857?v=4)](https://github.com/ymhuang0808 "ymhuang0808 (1 commits)")[![stevenbrookes](https://avatars.githubusercontent.com/u/43211757?v=4)](https://github.com/stevenbrookes "stevenbrookes (1 commits)")[![dinofratelli](https://avatars.githubusercontent.com/u/8737337?v=4)](https://github.com/dinofratelli "dinofratelli (1 commits)")[![do-samantha](https://avatars.githubusercontent.com/u/28718533?v=4)](https://github.com/do-samantha "do-samantha (1 commits)")

---

Tags

phpsdkshopify

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/roemerb-php-shopify/health.svg)

```
[![Health](https://phpackages.com/badges/roemerb-php-shopify/health.svg)](https://phpackages.com/packages/roemerb-php-shopify)
```

###  Alternatives

[phpclassic/php-shopify

PHP SDK for Shopify API

6044.0M6](/packages/phpclassic-php-shopify)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[jstolpe/instagram-graph-api-php-sdk

Instagram Graph API PHP SDK

13998.4k2](/packages/jstolpe-instagram-graph-api-php-sdk)[octw/aramex

A Library to integrate with Aramex APIs

2925.2k](/packages/octw-aramex)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
