A Laravel package for aiding in Shopify App development, similar to shopify_app
for Rails.
- Provide assistance in developing Shopify apps with Laravel
- Integration with Shopify API
- Authentication & installation for shops
- Auto install app webhooks and scripttags thorugh background jobs
- Provide basic ESDK views
- Handles and processes incoming webhooks
Here are the requirements to run this Laravel package.
Package | Version | Notes |
---|---|---|
php |
7 | Due to ohmybrew/basic-shopify-api |
laravel/framework |
5.4.* | For the package to work ;) |
ohmybrew/basic-shopify-api |
1.0.* | For API calls to Shopify |
First off, the best way is to use Composer to grab the code:
composer require ohmybrew/laravel-shopify
Open config/app.php
find providers
array. Find a line with:
App\Providers\RouteServiceProvider::class,
Before it, add a new line with:
\OhMyBrew\ShopifyApp\ShopifyAppProvider::class,
This ensures you can override the default routes.
Open config/app.php
find aliases
array. Add a new line with:
'ShopifyApp' => \OhMyBrew\ShopifyApp\Facades\ShopifyAppFacade::class,
Open app/Http/Kernel.php
find routeMiddleware
array. Add a new line with:
'auth.shop' => \OhMyBrew\ShopifyApp\Middleware\AuthShop::class,
'auth.webhook' => \OhMyBrew\ShopifyApp\Middleware\AuthWebhook::class,
Recommendations
By default Laravel uses the sync
driver to process jobs. These jobs run immediately and synchronously (blocking).
This package uses jobs to install webhooks and scripttags if any are defined in the configuration. If you do not have any scripttags or webhooks to install on the shop, you may skip this section.
If you do however, you can leave the sync
driver as default. But, it may impact load times for the customer accessing the app. Its recommended to setup Redis or database as your default driver in config/queue.php
. See Laravel's docs on setting up queue drivers.
For more information on creating webhooks, see docs/creating-webhooks.md
.
php artisan migrate
php artisan vendor:publish
You're now able to access config in config/shopify-app.php
. Essentially you will need to fill in the app_name
, api_key
, api_secret
, and api_scopes
to generate a working app. Items like webhooks
and scripttags
are completely optional depending on your app requirements.
In your app's settings on your Shopify Partner dashboard, you need to set the callback URL to be:
https://(your-domain).com/
And the redirect_uri
to be:
https://(your-domain).com/authenticate
The callback URL will point to the home route, while the redirect_uri
will point to the authentication route.
Information on getting started, overriding routes, controllers, is located in the docs
directory of this repo.
- Becoming a Shopify Developer
- Process in Authentication
- Developing Locally
- Creating Webhooks
- Overriding / Extending Package
Here are the defined routes and what they do.
Route | Notes |
---|---|
GET / | Displays home of app for authenticated shops |
GET /login | Displays login/install page |
POST/GET /authenticate | Authenticates the shop/installs the shop |
Using the facade:
// Returns instance of \OhMyBrew\ShopifyApp\Models\Shop
ShopifyApp::shop()
// Returns instance of \OhMyBrew\BasicShopifyAPI (ohmybrew/basic-shopify-api)
$shop = ShopifyApp::shop();
$shop->api()->request(...);
This project is released under the MIT license.