erdiko / shopify
Erdiko Shopify Package
Requires
- php: >=5.3.0
- guzzlehttp/guzzle: ~6.0
This package is not auto-updated.
Last update: 2024-11-15 04:04:53 UTC
README
Shopify API Adapter
- Connect to the Shopify API
- Guzzle support
- Convenient composer install
- PSR compliant
- Use with Erdiko or your favorite framework
If you are using composer and php 5.3 or greater, then this is a great package to use. It is compatible with frameworks such as Laravel, Symfony, SlimPHP, and of course Erdiko.
If you are using php 4 or are not using composer then check out ohShopify
Installation
via composer
composer require erdiko/shopify
Usage
To connect to shopify you can use the \erdiko\shopify\Shopify class to connect to the Shopify API. This library can be used within any PHP app that supports composer.
If you are using erdiko you can leverage our service models and sample app to jumpstart your development.
Authorizing your App with your Shopify Store
This module relies on OAuth to access and interact with your shopify stores. Authorization with this module is only required for setup, but it is required for each store.
The workflow of authorizing your application with OAuth is "asking for permission" by constructing a link to allow Shopify to install this application. You will need to expose your application to a URL from which you can redirect and access. Edit your routes config to expose the Shopify module controller to make sure we construct and output the expected output for Shopify like so:
{
"routes": {
...
"shop": "\erdiko\shopify\controllers\Shopify",
...
}
}
While we will defer you to the official Shopify Docs for complete instructions, here are the brief instructions to authorize your application with your store:
- Register your application with the Shopify Partners Dashboard
- Retrieve your API Key, API Secret and the Refresh Token (also known as a "nonce") for your newly created application
- Construct your "Permissions Prompt" URL by editing the following URL
https://{shop}.myshopify.com/admin/oauth/authorize?client_id={api_key}&scope={scopes}&redirect_uri={redirect_uri}&state={nonce}
Tokens:
- {shop}
- The subdomain for your shopify store
- {api_key}
- This is your API key
- {scopes}
- This is a comma separated list of permissions you allow for your application
- We would like to suggest the following:
write_products,write_orders,write_customers
- {nonce}
- Your Refresh Token, also known as a "nonce"
- {redirect_url}
- A publicily accessible route exposed by your erdiko application where the Shopify model is initialized
Erdiko App Skeleton
If you are using Erdiko, www.erdiko.org, there is some useful code for interacting with Shopify (beyond the basic API library).
To install this skeleton app in your existing Erdiko app it takes only 3 steps.
-
Copy the contents of the erdiko-shopify /app folder into the relavant /app folders in your site.
-
Modify app/config/default/shopify.json with your specific Shopify settings
-
Add a route to the Shopfy controller in your routes.json file. The class is /erdiko/shopify/controllers/Shopify.
Feedback
Please send us feedback if you have any questions or suggestions. If you find any bugs or find places where we are not PSR compliant please submit a github issue or email us.
Special Thanks
Arroyo Labs - For sponsoring development, http://arroyolabs.com
cmcdonaldca/ohShopify.php - Original Shopify PHP class