-
-
Notifications
You must be signed in to change notification settings - Fork 373
Installation v4.x.x
For v4.x.x, for v3.1.x click here.
First off, the best way is to use Composer to grab the code:
composer require ohmybrew/laravel-shopify
This will download laravel-shopify
for Laravel >= 5.5
.
With Laravel's auto-discover feature, this is handled for you on install.
This package expects a route named home
to exist. By default, the package has this route defined which shows a simple welcome page. To enable it, you will need to open routes/web.php
and comment out the default Laravel route for /
.
Optionally, to make your own, edit routes/web.php
and modify the default route to use the auth.shop
middleware with the home
named, example:
Route::get('/', function () {
return view('welcome');
})->middleware(['auth.shop'])->name('home');
Next, modify resources/views/welcome.blade.php
to extend this packages' layout for Shopify ESDK abilities, example:
@extends('shopify-app::layouts.default')
@section('content')
<p>You are: {{ ShopifyApp::shop()->shopify_domain }}</p>
@endsection
@section('scripts')
@parent
<script type="text/javascript">
// ESDK page and bar title
window.mainPageTitle = 'Welcome Page';
ShopifyApp.ready(function() {
ShopifyApp.Bar.initialize({
title: 'Welcome'
})
});
</script>
@endsection
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,
'auth.proxy' => \OhMyBrew\ShopifyApp\Middleware\AuthProxy::class,
'billable' => \OhMyBrew\ShopifyApp\Middleware\Billable::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, scripttags, and an option after-install hook if any are defined in the configuration. If you do not have any after-install hooks, 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
so jobs can run in the background and not affect the frontend performance. See Laravel's docs on setting up queue drivers.
For more information on creating webhooks, see Creating Webhooks of this wiki or After Authentication Job.
There is a default job provided which soft deletes the shop, and its charges (if any) for you. You're able to install this job directly or extend it.
To install, first run:
php artisan vendor:publish --tag=jobs
a job will be placed in App/Jobs/AppUninstalledJob
.
Next, edit config/shopify-app.php
to enable the job:
'webhooks' => [
[
'topic' => env('SHOPIFY_WEBHOOK_1_TOPIC', 'app/uninstalled'),
'address' => env('SHOPIFY_WEBHOOK_1_ADDRESS', 'https://(your-domain).com/webhook/app-uninstalled')
],
],
Use your environment file to replace the values, such as the domain, but set the topic to app/uninstalled
and the path as /webhook/app-uninstalled
will allow the webhook manager to do the heavy lifting for you.
php artisan vendor:publish --tag=migrations && php artisan migrate
php artisan vendor:publish --tag=config
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. As well, anything to do with billing is also optional, and is disabled by default.
Its recommended you use an env file for the configuration.
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.
By default ESDK is enabled, the embeddable mode for Shopify Apps. If you wish to disable this, set SHOPIFY_ESDK_ENABLED=0
for your environment variable. This will enabled legacy mode and skip any ESDK modes.
Please note, X-Frame-Options
header must be removed for ESDK to function. This package attempts to remove this header through the responses in Laravel, but this does not work for all cases. For Nginx, and Laravel Forge, you must specifically comment-out or remove the line below from the Nginx configuration:
add_header X-Frame-Options "SAMEORIGIN";
The Nginx configuration is found in Laravel Forge
at the very bottom of the page for the site in question: Files->Edit Nginx Configuration
road map
Welcome to the wiki!
Please see the homepage for a list of relevant pages.