Search by

msdev2 / shopify

mraganksoni

setup basic shopify app like install and all

Package info

github.com/msdev2/shopify

Forum

Wiki

pkg:composer/msdev2/shopify

Statistics

Installs: 145

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-12-03 18:37 UTC

This package is auto-updated.

Last update: 2026-12-04 03:41:58 UTC


README

setup basic shopify app like install and all

composer require msdev2/shopify

php artisan vendor:publish --provider="Msdev2\Shopify\ShopifyServiceProvider"

only public file php artisan vendor:publish --provider="Msdev2\Shopify\ShopifyServiceProvider" --tag="public" --force

  • update menu items
  • update plan
  • update billing

Add to config/app

'providers' => [
    /*
     * Package Service Providers...
     */
    Msdev2\Shopify\ShopifyServiceProvider::class,
]

To install shop

[domain]/install -- for ui
<a htef="{{ route('msdev2.install') }}">Install</a> -- for link of ui
https://[domain]/authenticate?shop=[shopify_domain] -- instent redirect

Update shopify app callback url

[shop]/auth/callback

Update ENV variables

SHOPIFY_API_KEY=63f2fa001d************
SHOPIFY_API_SECRET=47f72686a3************
SHOPIFY_APP_ID=548698745823
SHOPIFY_API_SCOPES=read_products,write_products
SHOPIFY_BILLING=true #false
SHOPIFY_FOOTER=<div>copyright @copy; all right reserved</div>
SHOPIFY_IS_EMBEDDED_APP=true #false //true if you want to open an app inside shopify else false
SHOPIFY_APPBRIDGE_ENABLED=true #true
SHOPIFY_ENABLE_ALPINEJS=true #true if you want to use vue make it false
SHOPIFY_ENABLE_TURBOLINKS=true #true if you want to use vue make it false
SHOPIFY_TEST_STORES=mraganksoni,msdev203
TAWK_URL=https://https://embed.tawk.to/64cbaca1cc26a871b02d0bcf/1h6tpkmh2
SHOPIFY_API_VERSION=2023-04

Setup hooks

update env
SHOPIFY_WEBHOOKS=APP_UNINSTALLED,THEMES_PUBLISH,SHOP_UPDATE
create hook receiver file
app/Webhook/Handlers/AppUninstalled.php
app/Webhook/Handlers/ShopUpdate.php
app/Webhook/Handlers/ThemesPublish.php

middleware lists

msdev2.shopify.verify  //to verify shop exist in url
msdev2.shopify.auth //to authenticate shopify user
msdev2.shopify.installed //to check if shopify is installed

setup layout for blade

css reference is https://www.uptowncss.com/

@extends('msdev2::layout.master')
@section('content')
<div class="mt-20">
    //your code here
</div>
@endsection
@section('scripts')
    @parent
    <script type="text/javascript">
        actions.TitleBar.create(app, { title: 'Welcome' });
    </script>
@endsection

helper functions

route helper functions

\Msdev2\Shopify\Utils::Route('home',['app'=>'home']) or mRoute('home',['app'=>'home])
\Msdev2\Shopify\Utils::Route('home') or mRoute('home')
\Msdev2\Shopify\Utils::Route('home.name') or mRoute('home.name')
\Msdev2\Shopify\Utils::Route('/pagename') or mRoute('/pagename')

other common helper functions

\Msdev2\Shopify\Utils::$shop;
\Msdev2\Shopify\Utils::getShop(?$shopname) or mShop(?$shopname)
\Msdev2\Shopify\Utils::getShopName() or mShopName()
\Msdev2\Shopify\Utils::rest(?$shop) or mRest(?$shop)
\Msdev2\Shopify\Utils::graph(?$shop) or mGraph(?$shop)
\Msdev2\Shopify\Utils::makeUrltoLinkFromString($string) or mUrltoLinkFromString($string)
\Msdev2\Shopify\Utils::successResponse(?$message,?$array,?$code) or mSuccessResponse(?$message,?$array,?$code)
\Msdev2\Shopify\Utils::errorResponse(?$message,?$array,?$code) or mErrorResponse(?$message,?$array,?$code)
mLog($message, ?$array, ?$logLevel, ?$channel)

for vuejs route helper

window.$GLOBALS.push(path)
window.$GLOBALS.push(path, params)
window.$GLOBALS.push(name)
window.$GLOBALS.push(name, params)
window.$GLOBALS.shop
window.$GLOBALS.host
window.$GLOBALS.csrfToken
window.$GLOBALS.processRequest(url, data, isImageRequest) # url = 'POST /url'  data = {} isImageRequest=false
window.$GLOBALS.showToast(msg,isError,subscribeFun,clearFun) # msg = string isError=false subscribeFun=callback function clearFun=callback function
showToast(msg,isError,subscribeFun,clearFun) # msg = string isError=false subscribeFun=callback function clearFun=callback function

save tabel to metafield

class ModelName extend \Msdev2\Shopify\Models\Model
{
    /** set true to save this data into metafield*/
    public $metaField = true;
    
}

use shopify logs

$shop->log('message',[],'type','channel') 
$shop->log('log added successfully',['test'=>'info'],'alert','shopify')

TLS

Keep TLS certificate verification enabled. Configure a trusted CA bundle if your server cannot validate HTTPS certificates.

Expiring offline tokens

New authorizations request expiring offline tokens and store the access token, refresh token, and their expirations. Before deploying, back up the database, verify the package's Shopify shops and sessions schemas, and run the package migrations as part of your approved deployment. The package's Shopify sessions table is not interchangeable with Laravel's standard database session table.

All web and queue workers, scheduler instances, and servers for an app must use the same lock-capable cache store (for example Redis or a correctly configured database cache), with consistent app credentials and cache prefix. The in-memory array cache and local file caches on separate servers cannot synchronize token rotation. Ensure token operations finish within the 60-second lock lease; monitor lock timeouts and database failures.

After deploying the new code to all workers, preview existing shops with php artisan msdev2:migrate-expiring-tokens --dry-run. Once approved, migrate a single shop with php artisan msdev2:migrate-expiring-tokens --shop=example.myshopify.com, then use php artisan msdev2:migrate-expiring-tokens for the remainder. This contacts Shopify and permanently invalidates the old non-expiring token; do not run old application versions or restore an old token backup after migration.

If a migration response is lost or saving it fails, stop other token operations for that shop and retry the same migration with its original stored token within seven days. Shopify's recovery window ends earlier if the new pair has been refreshed or retired by a later authorization. If recovery is no longer possible, the merchant must reauthorize. Never log token values.

Run Laravel's scheduler every minute. The package schedules msdev2:refresh-offline-tokens daily to renew tokens approaching refresh-token expiry, including dormant shops. Monitor scheduler failures, migration command exit status, token refresh errors, and Shopify's API logs; investigate shops requiring reauthorization before their refresh tokens expire. See Shopify's migration guide for the deadlines and how to identify remaining non-expiring token usage.

Regression checks

With Composer dependencies and PHP's SQLite extension installed, run php tests/offline_tokens.php (which also runs tests/regression.php).