Skip to content

Installation v3.x.x

Luke Walsh edited this page Dec 18, 2022 · 1 revision

For v3.x.x, for v2.x.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.

Providers

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,

Note: This package has a built in / (home) route.


Facades

Open config/app.php find aliases array. Add a new line with:

'ShopifyApp' => \OhMyBrew\ShopifyApp\Facades\ShopifyApp::class,

Middlewares

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,

Jobs

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.

Uninstalled Job (recommended)

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.


Migrations

php artisan vendor:publish --tag=migrations && php artisan migrate

Configuration

Package

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.


Shopify App

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.

ESDK & Legacy

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.