PHP Shopify Client for easy integration into your projects and apps
- PHP Client for working with the Shopify API
- Source code is well documented
- Heavily tested and maintained
- Production Shopify Apps are using
- Maintain a high standard of code quality
- Private apps support
- PHP cURL extension
- PHP >= 5.4
- See Travis CI for builds of each version
- Shopify Partner Account
composer require "dspacelabs/shopify:^1.0@dev"
<?php
use Dspacelabs\Component\Shopify\Client;
$client = new Client($accessKey, $secretKey);
$client->setShop('example.myshopify.com');
// This is the same thing as doing the entire domain
//$client->setShop('example');
// List of scopes can be in the Client class
$client->setScopes(
array(
Client::SCOPE_WRITE_CUSTOMERS,
Client::SCOPE_READ_CUSTOMERS
)
);
$nonce = time(); // Save in session, used in callback action
$authorizationUri = $client->getAuthorizationUrl('https://example.com/shopify/callback', $nonce);
// redirect user to $authorizationUri
<?php
use Dspacelabs\Component\Shopify\Client;
if (!$session->has('nonce')) {
throw new AccessedDeniedError();
}
$client = new Client($accessKey, $secretKey);
$client->setShop('example.myshopify.com');
// `isValid` takes array of query parameters, think $_GET, $_POST, etc.
// This example is using a Request object from the symfony/http-foundation
// library
if (!$client->isValid($request->query->all())) {
throw new \AccessDeniedError();
}
// Persist access token in database
$accessToken = $client->getAccessToken($request->query->get('code'));
<?php
use Dspacelabs\Component\Shopify\Client;
$client = new Client($accessKey, $secretKey):
$client
->setShop('example.myshopify.com')
->setAccessToken($accessToken);
$result = $client->call('GET', '/admin/customers.json');
// Process $result
@todo
@todo
See Generate private app credentials.
<?php
use Dspacelabs\Component\Shopify\Client;
/**
* The API Key and Password are generated for you on Shopify once you create
* Your private app. Those are the credentials you need here.
*/
$client = new Client($apiKey, $password):
$client
->setPrivate(true)
->setShop('example.myshopify.com');