Building a Shopify app with Laravel · Part 1 of 6
Project, CLI, app record and tunnel
Install the Shopify CLI, create the app record from the terminal, and run a fresh Laravel 13 app inside the Shopify admin through the CLI's tunnel or a named Cloudflare tunnel on your own domain.
By Abhishek Fouzdar
This part ends with a fresh Laravel app rendering inside the Shopify admin. Nothing in it is specific to reviews; it is the setup every Shopify app on Laravel needs, and the place where most first attempts stall. The series introduction explains what ReviewMini is.
Six words
Shopify has its own vocabulary. These six carry the whole series.
App record. The entry for your app in Shopify's systems: its name, its credentials, which permissions it asks for, where it is hosted. Lives in the Dev Dashboard, is created and edited from the terminal.
Client ID and client secret. The app record's credentials. The ID is public and ends up in committed files; the secret signs everything Shopify sends you and must never be committed.
Development store. A full Shopify store that charges nothing and cannot take real orders. The app is installed on it while you build.
Embedded app and App Home. An embedded app is one whose interface shows inside the Shopify admin, in an iframe. App Home is the page in that iframe, served by your Laravel app.
Tunnel. The admin loads App Home from a public HTTPS URL. During development that URL has to reach your laptop; a tunnel is what makes it.
TOML. The app's configuration lives in shopify.app.toml in your repository and is pushed to the app record with one command. Scopes, webhooks, metafields and the storefront proxy all go there.
Install the Shopify CLI and log in
The CLI is an npm package. Install it globally; the series used version 4.9.4.
npm install -g @shopify/cli
shopify version
4.9.4
Log in. The command opens a browser; sign in with the account that owns your dev organisation and come back to the terminal.
shopify auth login
If you have no development store yet, create one in the Dev Dashboard at dev.shopify.com under Stores. It gives you a <name>.myshopify.com domain and a storefront password; keep both to hand. The series uses saanjh-living.myshopify.com.
The Laravel app
A fresh install, plus Shopify's official package. The package is framework-agnostic; it verifies requests, exchanges tokens and calls the Admin API, and leaves routing, storage and rendering to you. Part 2 shows what that split looks like.
composer create-project laravel/laravel laravel-shopify-app-guide
cd laravel-shopify-app-guide
composer require shopify/shopify-app-php
Laravel 13.38 and shopify/shopify-app-php 1.0.2 at the time of writing. The package needs PHP 8.2 or later; Laravel 13 needs 8.3.
Create the app record from the terminal
Shopify recommends creating the app record with the CLI rather than by hand in the Dev Dashboard, and for good reason: the CLI writes the client ID into your configuration file and links the two, so there is nothing to copy. Run it from the project directory. It is interactive, so run it in a real terminal, not through an editor's task runner.
shopify app config link
? Which organization do you want to use?
✔ Your organization
? Create this project as a new app on Shopify?
✔ Yes, create it as a new app
? App name:
✔ ReviewMini
╭─ success ───────────────────────────────────────────────────────────────╮
│ shopify.app.toml is now linked to "ReviewMini" on Shopify │
│ Using shopify.app.toml as your default config. │
╰─────────────────────────────────────────────────────────────────────────╯
The CLI writes shopify.app.toml. What it generated:
# Learn more about configuring your app at https://shopify.dev/docs/apps/tools/cli/configuration
client_id = "fe474784a47726e6213eb880b74c9852"
name = "ReviewMini"
application_url = "https://shopify.dev/apps/default-app-home"
embedded = true
[access_scopes]
scopes = ""
[webhooks]
api_version = "2027-01"
[build]
include_config_on_deploy = true
automatically_update_urls_on_dev = true
[auth]
redirect_urls = [ "https://shopify.dev/apps/default-app-home/api/auth" ]
Two things to change before going on. The CLI picked 2027-01 as the webhooks API version, which on 23 October 2026 is the release candidate; pin the current stable version, 2026-10, and bump it deliberately each quarter. And the app needs scopes, the permissions a merchant grants it at install: ReviewMini reads products for its product search and writes them for the metafields in part 3. Here is the file as the repository has it after part 1:
# The app's configuration. `shopify app config link` created the app record and wrote client_id;
# `shopify app dev` keeps application_url and redirect_urls pointed at the current tunnel;
# `shopify app deploy` uploads the rest (scopes, webhooks, events) to Shopify.
client_id = "fe474784a47726e6213eb880b74c9852"
name = "ReviewMini"
application_url = "https://shopify.dev/apps/default-app-home"
embedded = true
[access_scopes]
scopes = "read_products,write_products"
[webhooks]
api_version = "2026-10"
[build]
include_config_on_deploy = true
automatically_update_urls_on_dev = true
[auth]
# Token exchange needs no OAuth redirect, but the CLI still wants one entry here and
# rewrites it to the tunnel during `shopify app dev`.
redirect_urls = [ "https://shopify.dev/apps/default-app-home/api/auth" ]
application_url and redirect_urls stay as placeholders. The next command replaces them on the app record every time it runs. The [auth] block exists because the CLI's schema wants one; this app never uses an OAuth redirect.
Tell the CLI how to run Laravel
A second file, shopify.web.toml, tells shopify app dev what to start and where to send traffic. The CLI runs the command, sets SERVER_PORT in its environment, and tunnels to that port. php artisan serve happens to read SERVER_PORT, so the two agree without a flag.
# Tells the Shopify CLI how to run this app during `shopify app dev`. The CLI starts the
# dev command below, sets SERVER_PORT (which `php artisan serve` reads), and tunnels to it.
name = "ReviewMini"
roles = ["frontend", "backend"]
webhooks_path = "/api/webhooks"
[commands]
dev = "php artisan serve"
roles says this one process serves both the page and the API. webhooks_path is where the CLI sends a test webhook on startup; it fails until part 5 and the CLI says so, which is fine.
Credentials and configuration
The CLI can write the client ID and secret into .env. It merges into the file and preserves everything else, and it prints the lines it changed.
shopify app env pull
- SHOPIFY_API_KEY=
- SHOPIFY_API_SECRET=
+ SHOPIFY_API_KEY=fe474784a47726e6213eb880b74c9852
+ SHOPIFY_API_SECRET=shpss_…
+ SCOPES=
Add the same keys, empty, to .env.example, plus the API version, and drop the SCOPES line, which the TOML already owns:
SHOPIFY_API_KEY=
SHOPIFY_API_SECRET=
SHOPIFY_API_VERSION=2026-10
A config file keeps env() calls out of the code and documents what each value is for. The third entry is for part 2.
config/shopify.php:
<?php
return [
// Client ID and secret of the app in the Dev Dashboard. The CLI injects both into the
// dev server's environment; .env carries them for everything else (queue workers, tests).
'api_key' => env('SHOPIFY_API_KEY'),
'api_secret' => env('SHOPIFY_API_SECRET'),
// Admin GraphQL API version. Pinned, bumped deliberately each quarter.
'api_version' => env('SHOPIFY_API_VERSION', '2026-10'),
// The route App Bridge uses to obtain a fresh ID token for a navigation that arrived
// without one. Must match the route registered in routes/web.php.
'patch_id_token_path' => '/auth/patch-id-token',
];
A page that proves the loop
Shopify opens App Home with ?shop=<store>.myshopify.com in the URL, inside an iframe. Browsers refuse to frame a page unless its Content-Security-Policy header allows the parent, so the page must send frame-ancestors naming that shop's admin. Part 2 replaces this route with the real verification; for now it validates the shop parameter and sets the header.
routes/web.php:
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
// App Home: the page Shopify loads in the admin iframe. Part 1 only proves the loop works;
// part 2 verifies the request and installs the shop before rendering anything.
Route::get('/', function (Request $request) {
// Shopify sends ?shop= when it opens the app. The CSP below lets only that shop's
// admin and admin.shopify.com frame this page; anything else is refused.
$shop = $request->query('shop', '');
abort_unless(preg_match('/^[a-z0-9][a-z0-9-]*\.myshopify\.com$/', $shop), 400, 'Missing or invalid shop');
return response()
->view('app')
->header('Content-Security-Policy', "frame-ancestors https://{$shop} https://admin.shopify.com");
});
The view loads two scripts from Shopify's CDN. App Bridge is the library that connects the iframe to the admin around it; it reads the client ID from the meta tag. Polaris 2 is the web-component library that makes <s-page> and friends render like the rest of the admin. Delete welcome.blade.php.
resources/views/app.blade.php:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ReviewMini</title>
{{-- App Bridge first, with the client ID; Polaris 2 after it, so it can read the admin's theme. --}}
<meta name="shopify-api-key" content="{{ config('shopify.api_key') }}">
<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js"></script>
<script src="https://cdn.shopify.com/shopifycloud/polaris-2.js"></script>
</head>
<body>
<s-page heading="ReviewMini">
<s-section heading="It works">
<s-paragraph>ReviewMini is running inside the Shopify admin. The real app starts in part 2.</s-paragraph>
</s-section>
</s-page>
</body>
</html>
Run it
shopify app dev --store saanjh-living.myshopify.com
╭─ info ──────────────────────────────────────────────────────────────────╮
│ Using shopify.app.toml for default values: │
│ • Org: Your organization │
│ • App: ReviewMini │
│ • Dev store: saanjh-living.myshopify.com │
│ • Update URLs: Yes │
╰─────────────────────────────────────────────────────────────────────────╯
Installing dependencies ...
Preview URL: https://admin.shopify.com/store/saanjh-living/apps/fe474784a47726e6213eb880b74c9852?dev-console=show
GraphiQL URL (Admin API): http://localhost:3457/graphiql?key=…
Proxy server started on port 33737
INFO Server running on [http://127.0.0.1:34363].
Sending APP_UNINSTALLED webhook to app server
APP_UNINSTALLED webhook delivery failed
✅ Ready, watching for changes in your app
│ Access scopes auto-granted: read_products, write_products
└ Using URL: https://duke-plot-prophet-brokers.trycloudflare.com
Read that from the bottom. The CLI opened a tunnel at a random trycloudflare.com address, pointed the app record's URLs at it, started php artisan serve on a port it chose, and put a proxy of its own in front. It granted the scopes on the dev store without a consent screen, which only dev stores allow. "Installing dependencies" was npm install, because the project has a package.json. The failed webhook is expected until part 5.
Open the preview URL. The admin shows ReviewMini in its sidebar and the page in the iframe reads "It works". Two requests reached Laravel, visible in the CLI's log.
Add /.shopify to .gitignore; the CLI keeps its working state there. Commit.
A tunnel on your own domain
The throwaway tunnel is right for a first run and for anyone without a domain. Its address changes on every start, which has a cost later: every URL stored on the app record, including the storefront proxy in part 6, moves with it, and a reinstall is sometimes needed. If you have a domain on Cloudflare, a named tunnel gives the app one fixed hostname for the whole project. The series uses reviewmini.shipbytes.dev.
Install cloudflared from Cloudflare's releases, then log in, which opens a browser and asks you to pick the zone:
cloudflared tunnel login
cloudflared tunnel create reviewmini
cloudflared tunnel route dns reviewmini reviewmini.shipbytes.dev
Created tunnel reviewmini with id ae73f287-…
Added CNAME reviewmini.shipbytes.dev which will route to this tunnel
A configuration file sends the hostname to a local port. Pick any free port; the CLI will be told to use it.
~/.cloudflared/config.yml:
tunnel: reviewmini
credentials-file: /home/you/.cloudflared/ae73f287-….json
ingress:
- hostname: reviewmini.shipbytes.dev
service: http://localhost:3000
- service: http_status:404
Run the tunnel in one terminal and the app in another. The --tunnel-url flag carries the port: the CLI starts its proxy on 3000 and still gives php artisan serve a port of its own behind it.
cloudflared tunnel run reviewmini
shopify app dev --store saanjh-living.myshopify.com --tunnel-url https://reviewmini.shipbytes.dev:3000
Proxy server started on port 3000
✅ Ready, watching for changes in your app
└ Using URL: https://reviewmini.shipbytes.dev
One detail worth knowing: the CLI updates the URLs on the app record, not in your local shopify.app.toml. The local file still says shopify.dev/apps/default-app-home. That matters in part 3, when shopify app deploy pushes the local file; with a fixed hostname you can set application_url to it then and stop thinking about it.
When it goes wrong
"Failed to prompt … This usually happens when running a command non-interactively." The CLI needed to ask a question and had no terminal. Run the command in a terminal window. The same message appears on shopify app dev when the project has a theme extension and the CLI needs the storefront password; part 6 covers that.
The admin shows a 404 for the app. The app is not installed on that store. The preview URL from shopify app dev installs it; if you uninstalled it, part 5 shows the install URL.
Nothing in the iframe, or a browser error about refusing to connect. The Content-Security-Policy header is missing or names the wrong shop. Request the tunnel URL with ?shop=<store>.myshopify.com and check the response headers.
Bad Request without ?shop=. Expected; the placeholder route refuses to render for anyone but Shopify. Part 2's verification refuses much more.
The CLI printed "Access scopes auto-granted" with fewer scopes than the TOML. Shopify collapses read_products into write_products, since write implies read. Harmless.
shopify app dev says it is using a different app or store than you expect. It remembers its last answers. Run it once with --reset.
Part 2 replaces the placeholder with authentication: what Shopify sends, how the package verifies it, and how the app gets an access token without ever redirecting the merchant.
New posts by email
Get new posts by email. Nothing else, no digests, unsubscribe in one click.
Comments
Comments are GitHub Discussions in shipbytes/discussions. Sign in with GitHub to post.
In this series
1 / 6- OverviewBuilding a Shopify app with Laravel
- Part 1Project, CLI, app record and tunnel
- Part 2Authentication with ID tokens and expiring access tokens
- Part 3Reviews, settings, product search and the rating metafields
- Part 4The admin UI with React, TypeScript and Polaris 2
- Part 5Webhooks, Events and the privacy topics
- Part 6App proxy, theme app extension and the end-to-end check