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

ActiveLibrary[API Development](/categories/api)

cadicvnn/shopify-php
====================

Simple Shopify API client in PHP

0.9.2(7y ago)248.2k↓38.2%2[1 PRs](https://github.com/cadicvnn/shopify-php/pulls)MITPHPPHP &gt;=5.3.0

Since Jan 27Pushed 4y ago3 watchersCompare

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

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

shopify-php
===========

[](#shopify-php)

[![Latest Stable Version](https://camo.githubusercontent.com/5d4b31fe12dfe15d78bb6ff4127965146ea64df342664fb8b66823ce39e7efe6/68747470733a2f2f706f7365722e707567782e6f72672f6f666673686f6f742f73686f706966792d7068702f762f737461626c652e706e67)](https://packagist.org/packages/offshoot/shopify-php) [![Total Downloads](https://camo.githubusercontent.com/ba05868fd904c5791688d5068e81033b7a71a2d1318013e2dd05904ad0d6e5bb/68747470733a2f2f706f7365722e707567782e6f72672f6f666673686f6f742f73686f706966792d7068702f646f776e6c6f6164732e706e67)](https://packagist.org/packages/offshoot/shopify-php) [![Latest Unstable Version](https://camo.githubusercontent.com/64d55e625a2f5cacfef23ce4ffc2367075b74fccd71e3b1fdad02d65092fe8a4/68747470733a2f2f706f7365722e707567782e6f72672f6f666673686f6f742f73686f706966792d7068702f762f756e737461626c652e706e67)](https://packagist.org/packages/offshoot/shopify-php) [![License](https://camo.githubusercontent.com/ddecc286c4068dd5194c3a8df0c1ea4667b2e5f462e495805601ad26188400b7/68747470733a2f2f706f7365722e707567782e6f72672f6f666673686f6f742f73686f706966792d7068702f6c6963656e73652e706e67)](https://packagist.org/packages/offshoot/shopify-php)

A simple [Shopify API](http://api.shopify.com/) client in PHP.

The canoncial repository for this stream of development is

This APII Client is still in a pre-1.0 state, so you can expect:

- some bugs (feel free to submit a pull request with bug fixes and test coverage)
- possibly some breaking API changes between v0.10 and v1.0

Requirements
------------

[](#requirements)

- PHP 5.3 (or higher)
- ext-curl, ext-json

Development Requirements
------------------------

[](#development-requirements)

- phpunit/phpunit 3.7

Getting Started
---------------

[](#getting-started)

Install shopify-php via [Composer](http://getcomposer.org/)

Create a `composer.json` file if you don't already have one in your projects root directory and require shopify-php:

```
{
  "require": {
    "cadicvnn/shopify-php": "dev-master"
  }
}

```

To learn more about Composer, including the complete installation process, visit

### Using cURL

[](#using-curl)

If you're using a cURL based HttpClient like the `CurlHttpClient`, you will want to include the cacert.pem file that can be found at

You can add this as a dependency in your composer file. Your `composer.json`might look something like this:

```
{
  "require": {
    "cadicvnn/shopify-php": "dev-master",
    "haxx-se/curl": "1.0.0"
  },
  "repositories": [
    {
      "type": "package",
      "package": {
        "name": "haxx-se/curl",
        "version": "1.0.0",
        "dist": {
          "url": "http://curl.haxx.se/ca/cacert.pem",
          "type": "file"
        }
      }
    }
  ]
}

```

You will be able to find the cacert.pem file in `vendor/haxx-se/curl/cacert.pem`

Usage
-----

[](#usage)

### Authentication

[](#authentication)

If you do not already have a Shopify API Permanent Access Token, you will need you authenticate with the Shopify API first

```
$pathToCertificateFile = "vendor/haxx-se/curl/cacert.pem";
$httpClient = new \Shopify\HttpClient\CurlHttpClient($pathToCertificateFile);

$redirector = new \Shopify\Redirector\HeaderRedirector();

$authenticate = new \Shopify\Api\AuthenticationGateway(
    $httpClient, $redirector
);

$authenticate->forShopName('mycoolshop')
    ->usingClientId('XXX1234567890') // get this from your Shopify Account
    ->withScope(array('write_products', 'read_orders'))
    ->andReturningTo("http://wherever.you/like")
    ->initiateLogin();

```

This will redirect your user to a Shopify login screen where they will need to authenticate with their Shopify credentials. After doing that, Shopify will perform a GET request to your redirect URI, that will look like:

```
GET http://wherever.you/like?code=TEMP_TOKEN

```

Your application will need to capture the `code` query param from the request and use that to get the permanent access token from Shopify

```
$client = new Shopify\Api\Client($httpClient);
$client->setClientSecret('ABC123XYZ');

// validate the Shopify Request
if ($client->isValidRequest($_GET)) {

    // exchange the token
    $permanentAccessToken = $authenticate->forShopName('mycoolshop')
        ->usingClientId('XXX1234567890')
        ->usingClientSecret('ABC123XYZ')
        ->toExchange($_GET['code']);

}

```

#### TODO: build request validation into exchange process

[](#todo-build-request-validation-into-exchange-process)

#### TODO: have AuthenticationGateway extend Api\\Client

[](#todo-have-authenticationgateway-extend-apiclient)

### Interacting with the Shopify API

[](#interacting-with-the-shopify-api)

Once you have a valid Shopify Permanent Access Token, you can start making calls to the Shopify API

First setup an instance of the Shopify API client.

```
$client = new \Shopify\Api\Client($httpClient);
$client->setAccessToken($permanentAccessToken);
$client->setClientSecret('ABC123XYZ');
$client->setShopName('mycoolshop');

```

Then you're ready to start interacting with the Shopify API. Maybe you want to get all of the products from your store

```
$products = $client->get('/admin/products.json', array(
    'collection_id' => '987654321'
));

```

Maybe you want to get the details of a specific order

```
$order = $client->get('/admin/orders/123456789.json');

```

Or maybe you want to create a new Order

```
$order = $client->post('/admin/orders.json', array(
    'order' => array(
        'line_items' => array(
            0 => array(
                'grams' => 1300,
                'price' => 74.99,
                'quantity' => 3,
                'title' => "Big Brown Bear Boots",
            ),
        ),
        'tax_lines' => array(
            0 => array(
                'price' => 29.25,
                'rate' => 0.13,
                'title' => "HST",
            ),
        ),
        'transactions' => array(
            0 => array(
                'amount' => 254.22,
                'kind' => "sale",
                'status' => "success",
            )
        ),
        'total_tax' => 29.25,
        'currency' => "CAD",
    )
));

```

#### TODO: Implement PUT and DELETE functionality

[](#todo-implement-put-and-delete-functionality)

Contributing
------------

[](#contributing)

Contributions are welcome. Just fork the repository and send a pull request. Please be sure to include test coverage with your pull request. You can learn more about Pull Requests [here](https://help.github.com/articles/creating-a-pull-request)

In order to run the test suite, ensure that the development dependencies have been installed via composer. Then from your command line, simple run:

```
vendor/bin/phpunit --bootstrap tests/bootstrap.php tests/

```

License
-------

[](#license)

This library is released under the [MIT License](https://github.com/TeamOffshoot/shopify-php/blob/master/LICENSE.txt)

Acknowledgements
----------------

[](#acknowledgements)

Thanks to [Sandeep Shetty](https://github.com/sandeepshetty/shopify_api) for his development of the initial code base.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.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 ~848 days

Total

3

Last Release

2797d ago

### Community

Maintainers

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

---

Top Contributors

[![chriswoodford](https://avatars.githubusercontent.com/u/249055?v=4)](https://github.com/chriswoodford "chriswoodford (53 commits)")[![sandeepshetty](https://avatars.githubusercontent.com/u/20508?v=4)](https://github.com/sandeepshetty "sandeepshetty (22 commits)")[![cadicvnn](https://avatars.githubusercontent.com/u/225918?v=4)](https://github.com/cadicvnn "cadicvnn (10 commits)")[![nmtien](https://avatars.githubusercontent.com/u/4736608?v=4)](https://github.com/nmtien "nmtien (7 commits)")[![baorv](https://avatars.githubusercontent.com/u/9483946?v=4)](https://github.com/baorv "baorv (4 commits)")[![khanhdaik134](https://avatars.githubusercontent.com/u/37681198?v=4)](https://github.com/khanhdaik134 "khanhdaik134 (1 commits)")

---

Tags

apishopify

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[kyon147/laravel-shopify

Shopify package for Laravel to aide in app development

473252.9k](/packages/kyon147-laravel-shopify)[robwittman/shopify-php-sdk

PHP SDK for Shopify API

7098.9k1](/packages/robwittman-shopify-php-sdk)[zfr/zfr-shopify

PHP library for interacting with the Shopify REST API

37198.8k](/packages/zfr-zfr-shopify)[luketowers/php-shopify-api

PHP wrapper for Shopify API

3410.1k](/packages/luketowers-php-shopify-api)[dan/shopify-api

Shopify API for PHP

218.1k](/packages/dan-shopify-api)

PHPackages © 2026

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