sonu179208 / shopify-sdk
Framework-agnostic PHP SDK for Shopify REST & GraphQL APIs
v1.0.0
2025-07-07 15:24 UTC
Requires
- php: >=7.4
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
- GitHub: @sonu179208
- Email: sonu179208@gmail.com