ordersify / shopify-api-php
Shopify API Client for PHP
Installs: 1 647
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 50
pkg:composer/ordersify/shopify-api-php
Requires
- php: >=5.6.0
 - doctrine/cache: ^1.0
 - doctrine/inflector: ^1.0|^2.0
 - guzzlehttp/guzzle: ^6.0|^7.0
 - jms/serializer: ^1.0
 - slince/di: ^3.0
 - symfony/yaml: ^2.0|^3.0|^4.0
 
Requires (Dev)
- phpunit/phpunit: ^5.0|^6.0
 - symfony/filesystem: ^2.0|^3.0|^4.0
 - symfony/property-access: ^2.0|^3.0|^4.0
 
- dev-master
 - 4.x-dev
 - 3.x-dev
 - v2.4.20
 - 2.4.19
 - 2.4.18
 - 2.4.17
 - 2.4.16
 - 2.4.15
 - 2.4.14
 - 2.4.13
 - v2.4.12
 - 2.4.11
 - 2.4.10
 - 2.4.9
 - 2.4.8
 - 2.4.7
 - 2.4.6
 - 2.4.5
 - 2.4.4
 - 2.4.3
 - 2.4.2
 - 2.4.1
 - 2.4.0
 - 2.3.2
 - 2.3.1
 - 2.3.0
 - 2.2.0
 - 2.1.2
 - 2.1.1
 - 2.1.0
 - 2.0.3
 - 2.0.2
 - 2.0.1
 - 2.0.0-beta1
 - 1.0.0-beta2
 - 1.0.0-beta1
 - dev-scrutinizer-patch-1
 - dev-revert-24-admin-graphql-api-id
 
This package is auto-updated.
Last update: 2025-10-22 08:46:57 UTC
README
🚀 PHP SDK for the Shopify API
Installation
Install via composer
$ composer require slince/shopify-api-php
Quick Start
Initialize the client
You first need to initialize the client. For that you need your Shop Name and AccessToken
require __DIR__ . '/vendor/autoload.php'; $credential = new Slince\Shopify\PublicAppCredential('Access Token'); // Or Private App $credential = new Slince\Shopify\PrivateAppCredential('API KEY', 'PASSWORD', 'SHARED SECRET'); $client = new Slince\Shopify\Client($credential, 'your-store.myshopify.com', [ 'metaCacheDir' => './tmp' // Metadata cache dir, required ]);
Use Manager to manipulate your data;
- Lists products
 
$products = $client->getProductManager()->findAll([ // Filter your product 'collection_id' => 841564295 'page' => 2 // deprecated ]);
- Lists products by pagination
 
$pagination = $client->getProductManager()->paginate([ // filter your product 'limit' => 3, 'created_at_min' => '2015-04-25T16:15:47-04:00' ]); // $pagination is instance of `Slince\Shopify\Common\CursorBasedPagination` $currentProducts = $pagination->current(); //current page while ($pagination->hasNext()) { $nextProducts = $pagination->next(); } # to persist across requests you can use next_page_info and previous_page_info $nextPageInfo = $pagination->getNextPageInfo(); $prevPageInfo = $pagination->getPrevPageInfo(); $products = $pagination->current($nextPageInfo);
- Get the specified product
 
$product = $client->getProductManager()->find(12800); // Update the given product $product = $client->getProductManager()->update(12800, [ "title" => "Burton Custom Freestyle 151", "body_html" => "<strong>Good snowboard!<\/strong>", "vendor"=> "Burton", "product_type" => "Snowboard", ]);
- Creates a new product
 
$product = $client->getProductManager()->create([ "title" => "Burton Custom Freestyle 151", "body_html" => "<strong>Good snowboard!<\/strong>", "vendor"=> "Burton", "product_type" => "Snowboard", ]);
- Removes the product by its id
 
$client->getProductManager()->remove(12800);
The product is an instance of Slince\Shopify\Manager\Product\Product; You can access properties like following:
echo $product->getTitle(); echo $product->getCreatedAt(); // DateTime Object //... print_r($product->getVariants()); print_r($product->getImages());
Available managers:
- Article
 - Asset
 - Blog
 - CarrierService
 - Collect
 - Comment
 - Country
 - CustomCollection
 - Customer
 - CustomerAddress
 - CustomerSavedSearch
 - DiscountCode
 - DraftOrder
 - Fulfillment
 - FulfillmentService
 - InventoryItem
 - InventoryLevel
 - Location
 - Order
 - OrderRisk
 - Page
 - Policy
 - PriceRule
 - Product
 - ProductImage
 - ProductVariant
 - Province
 - RecurringApplicationCharge
 - Redirect
 - Refund
 - ScriptTag
 - ShippingZone
 - Shop
 - SmartCollection
 - Theme
 - Transaction
 - Webhook
 
You can access the manager like $client->getProductManager(), $client->getOrderManager().
Basic CURD
If you don't like to use managers, you can also manipulate data like this:
The returned value is just an array;
$products = $client->get('products', [ // Filter your products ]); $product = $client->get('products/12800'); $product = $client->post('products', [ "product" => [ "title" => "Burton Custom Freestyle 151", "body_html" => "<strong>Good snowboard!<\/strong>", "vendor"=> "Burton", "product_type" => "Snowboard", "images" => [ [ "attachment" => "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" ] ] ] ]); $product = $client->put('products/12800', [ "product" => [ "title" => "Burton Custom Freestyle 151", "body_html" => "<strong>Good snowboard!<\/strong>", "vendor"=> "Burton", "product_type" => "Snowboard", "images" => [ [ "attachment" => "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" ] ] ] ]); $client->delete('products/12800');
LICENSE
The MIT license. See MIT