sonu179208/shopify-sdk

Framework-agnostic PHP SDK for Shopify REST & GraphQL APIs

v1.0.0 2025-07-07 15:24 UTC

This package is auto-updated.

Last update: 2025-07-07 15:38:37 UTC


README

# Shopify SDK for PHP

A lightweight, framework-agnostic PHP SDK for interacting with the Shopify REST and GraphQL APIs. Easily integrate Shopify into any PHP app โ€” Laravel, CodeIgniter, or Core PHP.

---

## ๐Ÿ› ๏ธ Installation

Install via Composer:

```bash
composer require sonu179208/shopify-sdk

๐Ÿš€ Quick Start

require 'vendor/autoload.php';

use ShopifySDK\Shopify;

$shopify = new Shopify("yourstore.myshopify.com", "your-access-token");

// Get all products
$response = $shopify->get("products.json");

print_r($response);

๐Ÿงฉ REST API Usage (CRUD)

โœ… Create Product

$newProduct = [
    "product" => [
        "title" => "New Product",
        "body_html" => "<strong>Awesome product</strong>",
        "vendor" => "Sonu Inc.",
        "product_type" => "Custom"
    ]
];

$response = $shopify->post("products.json", $newProduct);

๐Ÿ” Read Products

$response = $shopify->get("products.json");

โœ๏ธ Update Product

$productId = 1234567890;

$update = [
    "product" => [
        "id" => $productId,
        "title" => "Updated Product Title"
    ]
];

$response = $shopify->put("products/{$productId}.json", $update);

โŒ Delete Product

$productId = 1234567890;
$response = $shopify->delete("products/{$productId}.json");

โšก GraphQL API Usage

โœ… Run a GraphQL Query

$query = <<<GQL
{
  shop {
    name
    myshopifyDomain
  }
}
GQL;

$response = $shopify->graphql($query);

๐Ÿงช Create Product via GraphQL (Mutation)

$mutation = <<<GQL
mutation {
  productCreate(input: {
    title: "GraphQL Product",
    bodyHtml: "Product via GraphQL"
  }) {
    product {
      id
      title
    }
    userErrors {
      field
      message
    }
  }
}
GQL;

$response = $shopify->graphql($mutation);

๐Ÿ”” Webhook Management

Create Webhook

$response = $shopify->registerWebhook("orders/create", "[https://yourdomain.com/webhooks/order-created](https://yourdomain.com/webhooks/order-created)");

List Webhooks

$response = $shopify->listWebhooks();

Delete Webhook

$webhookId = 123456789;
$response = $shopify->deleteWebhook($webhookId);

๐Ÿงฑ Framework Compatibility

  • โœ… Laravel
  • โœ… CodeIgniter
  • โœ… Symfony
  • โœ… Core PHP
  • โœ… Any modern PHP app (PHP 7.4+)

๐Ÿ‘จโ€๐Ÿ’ป Author

Sonu Kumar