{"id":13546437,"url":"https://github.com/slince/shopify-api-php","last_synced_at":"2025-04-04T16:15:23.656Z","repository":{"id":41190315,"uuid":"97690649","full_name":"slince/shopify-api-php","owner":"slince","description":":rocket: Shopify API Client for PHP","archived":false,"fork":false,"pushed_at":"2023-10-22T12:52:28.000Z","size":776,"stargazers_count":129,"open_issues_count":18,"forks_count":48,"subscribers_count":14,"default_branch":"3.x","last_synced_at":"2025-03-28T15:08:17.963Z","etag":null,"topics":["api","sdk","shopify","shopify-api","shopify-client","shopify-php","shopify-sdk"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slince.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-07-19T08:11:22.000Z","updated_at":"2025-03-23T08:34:05.000Z","dependencies_parsed_at":"2022-07-14T10:21:40.165Z","dependency_job_id":"326cdd9d-ebab-4ba9-9c2a-a1b73748b495","html_url":"https://github.com/slince/shopify-api-php","commit_stats":{"total_commits":205,"total_committers":13,"mean_commits":15.76923076923077,"dds":"0.23902439024390243","last_synced_commit":"fd5c218726276d5dac9f5e8687ce13cd8113eb20"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fshopify-api-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fshopify-api-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fshopify-api-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fshopify-api-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slince","download_url":"https://codeload.github.com/slince/shopify-api-php/tar.gz/refs/heads/3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208154,"owners_count":20901570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","sdk","shopify","shopify-api","shopify-client","shopify-php","shopify-sdk"],"created_at":"2024-08-01T12:00:37.464Z","updated_at":"2025-04-04T16:15:23.636Z","avatar_url":"https://github.com/slince.png","language":"PHP","funding_links":[],"categories":["Libraries","库"],"sub_categories":["PHP"],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://cdn.shopify.com/shopify-marketing_assets/builds/19.0.0/shopify-full-color-black.svg\" width=\"300\"/\u003e \n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e:rocket: PHP SDK for the Shopify API\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"LICENSE\" target=\"_blank\"\u003e\n        \u003cimg alt=\"Software License\" src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/slince/shopify-api-php/actions\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/slince/shopify-api-php/test.yml?style=flat-square\" alt=\"Build Status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codecov.io/github/slince/shopify-api-php\"\u003e\n        \u003cimg src=\"https://img.shields.io/codecov/c/github/slince/shopify-api-php/3.x?style=flat-square\" alt=\"Coverage Status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/slince/shopify-api-php\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/v/slince/shopify-api-php.svg?style=flat-square\u0026amp;label=stable\" alt=\"Latest Stable Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/slince/shopify-api-php/?branch=master\"\u003e\n        \u003cimg src=\"https://img.shields.io/scrutinizer/g/slince/shopify-api-php.svg?style=flat-square\" alt=\"Scrutinizer\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/slince/shopify-api-php\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/dt/slince/shopify-api-php.svg?style=flat-square\" alt=\"Total Downloads\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Installation\n\nInstall via composer\n\n```bash\n$ composer require slince/shopify-api-php\n```\n\n## Quick Start\n\n### Initialize the client\n\nYou first need to initialize the client. For that you need your Shop Name and AccessToken\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\n$credential = new Slince\\Shopify\\PublicAppCredential('Access Token');\n// Or Private App\n$credential = new Slince\\Shopify\\PrivateAppCredential('API KEY', 'PASSWORD', 'SHARED SECRET');\n\n$client = new Slince\\Shopify\\Client('your-store.myshopify.com', $credential, [\n    'meta_cache_dir' =\u003e './tmp' // Metadata cache dir, required\n]);\n```\n\n### Middleware\n\nMiddleware augments the functionality of handlers by invoking them in the process of generating responses. Middleware is implemented as a higher order function that takes the following form.\n\n```php\n\n$middleware = function(\\Psr\\Http\\Message\\ServerRequestInterface $request, callable $next){\n    $response = $next($request);\n    $this-\u003elogger-\u003elog($request, $response);\n    return $response;\n};\n\n$client-\u003egetMiddlewares()-\u003epush($middleware);\n```\nBuilt-in middleware:\n\n- [DelayMiddleware](src/Middleware/DelayMiddleware.php) \n\n### Exception\n\nThe Client throws the following types of exceptions.\n\n- [BadRequestException](src/Exception/BadRequestException.php) 400\n- [UnauthorizedException](src/Exception/UnauthorizedException.php) 401\n- [PaymentRequiredException](src/Exception/PaymentRequiredException.php) 402\n- [ForbiddenException](src/Exception/ForbiddenException.php) 403\n- [NotFoundException](src/Exception/NotFoundException.php) 404\n- [NotAcceptableException](src/Exception/NotAcceptableException.php) 406\n- [UnprocessableEntityException](src/Exception/UnprocessableEntityException.php) 422\n- [TooManyRequestsException](src/Exception/TooManyRequestsException.php) 429\n- [ClientException](src/Exception/ClientException.php) other\n\n### Use Manager to manipulate your data;\n\n* Lists products\n```php\n$products = $client-\u003egetProductManager()-\u003efindAll([\n    // Filter your product\n    'collection_id' =\u003e 841564295\n    'page' =\u003e 2 // deprecated\n]);\n```\n\n* Lists products by pagination\n\n```php\n$pagination = $client-\u003egetProductManager()-\u003epaginate([\n    // filter your product\n    'limit' =\u003e 3,\n    'created_at_min' =\u003e '2015-04-25T16:15:47-04:00'\n]);\n// $pagination is instance of `Slince\\Shopify\\Common\\CursorBasedPagination`\n\n$currentProducts = $pagination-\u003ecurrent(); //current page\n\nwhile ($pagination-\u003ehasNext()) {\n    $nextProducts = $pagination-\u003enext();\n}\n\n# to persist across requests you can use next_page_info and previous_page_info\n$nextPageInfo = $pagination-\u003egetNextPageInfo();\n$prevPageInfo = $pagination-\u003egetPrevPageInfo();\n\n$products = $pagination-\u003ecurrent($nextPageInfo);\n```\n\n* Get the specified product\n```php\n$product = $client-\u003egetProductManager()-\u003efind(12800);\n\n// Update the given product\n$product = $client-\u003egetProductManager()-\u003eupdate(12800, [\n      \"title\" =\u003e \"Burton Custom Freestyle 151\",\n      \"body_html\" =\u003e \"\u003cstrong\u003eGood snowboard!\u003c\\/strong\u003e\",\n      \"vendor\"=\u003e \"Burton\",\n      \"product_type\" =\u003e \"Snowboard\",\n]);\n```\n\n* Creates a new product\n```php\n$product = $client-\u003egetProductManager()-\u003ecreate([\n      \"title\" =\u003e \"Burton Custom Freestyle 151\",\n      \"body_html\" =\u003e \"\u003cstrong\u003eGood snowboard!\u003c\\/strong\u003e\",\n      \"vendor\"=\u003e \"Burton\",\n      \"product_type\" =\u003e \"Snowboard\",\n]);\n```\n\n* Removes the product by its id\n```php\n$client-\u003egetProductManager()-\u003eremove(12800);\n```\nThe product is an instance of `Slince\\Shopify\\Manager\\Product\\Product`; You can access properties like following:\n \n```php\necho $product-\u003egetTitle();\necho $product-\u003egetCreatedAt(); // DateTime Object\n//...\nprint_r($product-\u003egetVariants());\nprint_r($product-\u003egetImages());\n```\n\nAvailable managers:\n\n- [Access\\AccessScope](src/Service/Access/AccessScopeManagerInterface.php)\n- [Access\\StorefrontAccessToken](src/Service/Access/StorefrontAccessTokenManagerInterface.php)\n- [Analytics\\Report](src/Service/Analytics/ReportManagerInterface.php)\n- [Billing\\ApplicationCharge](src/Service/Billing/ApplicationChargeManagerInterface.php)\n- [Billing\\ApplicationCredit](src/Service/Billing/ApplicationCreditManagerInterface.php)\n- [Billing\\RecurringApplicationCharge](src/Service/Billing/RecurringApplicationChargeManagerInterface.php)\n- [Billing\\UsageCharge](src/Service/Billing/UsageChargeManagerInterface.php)\n- [Customers\\Address](src/Service/Customers/AddressManagerInterface.php)\n- [Customers\\Customer](src/Service/Customers/CustomerManagerInterface.php)\n- [Customers\\CustomerSavedSearch](src/Service/Customers/CustomerSavedSearchManagerInterface.php)\n- [Discounts\\DiscountCode](src/Service/Discounts/DiscountCodeManagerInterface.php)\n- [Discounts\\PriceRule](src/Service/Discounts/PriceRuleManagerInterface.php)\n- [Events\\Event](src/Service/Events/EventManagerInterface.php)\n- [Events\\Webhook](src/Service/Events/WebhookManagerInterface.php)\n- [Inventory\\InventoryItem](src/Service/Inventory/InventoryItemManagerInterface.php)\n- [Inventory\\InventoryLevel](src/Service/Inventory/InventoryLevelManagerInterface.php)\n- [Inventory\\Location](src/Service/Inventory/LocationManagerInterface.php)\n- [MarketingEvent\\MarketingEvent](src/Service/MarketingEvent/MarketingEventManagerInterface.php)\n- [OnlineStore\\Article](src/Service/OnlineStore/ArticleManagerInterface.php)\n- [OnlineStore\\Asset](src/Service/OnlineStore/AssetManagerInterface.php)\n- [OnlineStore\\Blog](src/Service/OnlineStore/BlogManagerInterface.php)\n- [OnlineStore\\Comment](src/Service/OnlineStore/CommentManagerInterface.php)\n- [OnlineStore\\Page](src/Service/OnlineStore/PageManagerInterface.php)\n- [OnlineStore\\Redirect](src/Service/OnlineStore/RedirectManagerInterface.php)\n- [OnlineStore\\ScriptTag](src/Service/OnlineStore/ScriptTagManagerInterface.php)\n- [OnlineStore\\Theme](src/Service/OnlineStore/ThemeManagerInterface.php)\n- [Orders\\DraftOrder](src/Service/Orders/DraftOrderManagerInterface.php)\n- [Orders\\Order](src/Service/Orders/OrderManagerInterface.php)\n- [Orders\\Refund](src/Service/Orders/RefundManagerInterface.php)\n- [Orders\\Risk](src/Service/Orders/RiskManagerInterface.php)\n- [Orders\\Transaction](src/Service/Orders/TransactionManagerInterface.php)\n- [Products\\Collect](src/Service/Products/CollectManagerInterface.php)\n- [Products\\CustomCollection](src/Service/Products/CustomCollectionManagerInterface.php)\n- [Products\\Image](src/Service/Products/ImageManagerInterface.php)\n- [Products\\Product](src/Service/Products/ProductManagerInterface.php)\n- [Products\\SmartCollection](src/Service/Products/SmartCollectionManagerInterface.php)\n- [Products\\Variant](src/Service/Products/VariantManagerInterface.php)\n- [Shipping\\AssignedFulfillmentOrder](src/Service/Shipping/AssignedFulfillmentOrderManagerInterface.php)\n- [Shipping\\CarrierService](src/Service/Shipping/CarrierServiceManagerInterface.php)\n- [Shipping\\Fulfillment](src/Service/Shipping/FulfillmentManagerInterface.php)\n- [Shipping\\FulfillmentOrder](src/Service/Shipping/FulfillmentOrderManagerInterface.php)\n- [Shipping\\FulfillmentService](src/Service/Shipping/FulfillmentServiceManagerInterface.php)\n- [Store\\Country](src/Service/Store/CountryManagerInterface.php)\n- [Store\\Currency](src/Service/Store/CurrencyManagerInterface.php)\n- [Store\\Policy](src/Service/Store/PolicyManagerInterface.php)\n- [Store\\Province](src/Service/Store/ProvinceManagerInterface.php)\n- [Store\\ShippingZone](src/Service/Store/ShippingZoneManagerInterface.php)\n- [Store\\Shop](src/Service/Store/ShopManagerInterface.php)\n\nYou can access the manager like `$client-\u003egetProductManager()`, `$client-\u003egetOrderManager()`. \n\n### Basic CURD\n\nIf you don't like to use managers, you can also manipulate data like this: \n\nThe returned value is just an array;\n\n```php\n$products = $client-\u003eget('products', [\n    // Filter your products\n]);\n\n$product = $client-\u003eget('products/12800');\n\n$product = $client-\u003epost('products', [\n    \"product\" =\u003e [\n        \"title\" =\u003e \"Burton Custom Freestyle 151\",\n        \"body_html\" =\u003e \"\u003cstrong\u003eGood snowboard!\u003c\\/strong\u003e\",\n        \"vendor\"=\u003e \"Burton\",\n        \"product_type\" =\u003e \"Snowboard\",\n        \"images\" =\u003e [\n            [ \n                \"attachment\" =\u003e \"R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAw==\\n\"\n            ]\n        ]\n     ]\n]);\n\n$product = $client-\u003eput('products/12800', [\n    \"product\" =\u003e [\n        \"title\" =\u003e \"Burton Custom Freestyle 151\",\n        \"body_html\" =\u003e \"\u003cstrong\u003eGood snowboard!\u003c\\/strong\u003e\",\n        \"vendor\"=\u003e \"Burton\",\n        \"product_type\" =\u003e \"Snowboard\",\n        \"images\" =\u003e [\n            [ \n                \"attachment\" =\u003e \"R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAw==\\n\"\n            ]\n        ]\n     ]\n]);\n\n$client-\u003edelete('products/12800');\n```\n## LICENSE\n\nThe MIT license. See [MIT](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslince%2Fshopify-api-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslince%2Fshopify-api-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslince%2Fshopify-api-php/lists"}