使用 Shopify CLI 创建应用(基于 PHP 应用程序模板),且在商店中安装
1、导航到要在其中创建应用程序的目录(E:\wwwroot\shopify-app)。您的应用程序将在一个新的子目录中创建。如图1
PS E:\wwwroot\shopify-app> pwd Path ---- E:\wwwroot\shopify-app
2、运行以下命令之一以创建新应用,然后选择要开始使用的应用模板的语言:Node、PHP 或 Ruby。选择 PHP。下图显示了在终端中成功创建的应用程序。如图2
PS E:\wwwroot\shopify-app> yarn create @shopify/app yarn create v1.22.15 [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... warning Your current version of Yarn is out of date. The latest version is "1.22.19", while you're on "1.22.15". success Installed "@shopify/create-app@3.16.3" with binaries: - create-app Welcome. Let’s get started by naming your app. You can change it later. ✔ Your app's name? · learn-app ✔ Which template would you like to use? · php ✔ Downloaded template from https://github.com/Shopify/shopify-app-template-php#cli_three ✔ App initialized ✔ Liquid parsed ✔ Updated package.json ✔ Dependencies installed with yarn ✔ Installed dependencies in / ✔ Installed dependencies in /web/frontend/ ✔ Completed clean up ✔ Git repository initialized learn-app is ready for you to build! Remember to cd learn-app Check the setup instructions in your README file To preview your project, run yarn dev To add extensions, run yarn generate extension For more details on all that you can build, see the docs: shopify.dev (https://shopify.dev) ✨ For help and a list of commands, enter yarn shopify app --help Done in 1828.53s.
3、启动本地开发服务器。导航到您新创建的应用程序目录:E:\wwwroot\shopify-app\learn-app
4、设置你的 Laravel 应用。参考:https://github.com/Shopify/shopify-app-template-php/tree/cli_three#setting-up-your-laravel-app 。由于 Windows 终端中 touch 命令不可用,在 PhpStorm 中新建 storage/db.sqlite。新建路径中的数据源,驱动程序选择 SQLite,名称为 db。如图3、图4
PS E:\wwwroot\shopify-app\learn-app> cd web PS E:\wwwroot\shopify-app\learn-app\web> ls 目录: E:\wwwroot\shopify-app\learn-app\web Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2022/10/14 14:54 app d----- 2022/10/14 14:54 bootstrap d----- 2022/10/14 14:54 config d----- 2022/10/14 14:54 database d----- 2022/10/14 14:54 frontend d----- 2022/10/14 14:54 public d----- 2022/10/14 14:54 resources d----- 2022/10/14 14:54 routes d----- 2022/10/14 14:54 storage -a---- 2022/10/14 14:50 261 .env.example -a---- 2022/10/14 14:50 370 .env.testing -a---- 2022/10/14 14:50 1743 artisan -a---- 2022/10/14 14:50 2282 composer.json -a---- 2022/10/14 14:50 469 entrypoint.sh -a---- 2022/10/14 14:50 898 nginx.conf -a---- 2022/10/14 14:50 1233 phpunit.xml -a---- 2022/10/14 14:50 584 server.php -a---- 2022/10/14 14:50 80 shopify.web.toml PS E:\wwwroot\shopify-app\learn-app\web> composer install No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information. Loading composer repositories with package information Info from https://repo.packagist.org: #StandWithUkraine Updating dependencies Lock file operations: 114 installs, 0 updates, 0 removals - Locking brick/math (0.9.3) - Locking dflydev/dot-access-data (v3.0.1) - Locking doctrine/cache (2.2.0) - Locking doctrine/dbal (3.4.5) - Locking doctrine/deprecations (v1.0.0) - Locking doctrine/event-manager (1.2.0) - Locking doctrine/inflector (2.0.5) - Locking doctrine/instantiator (1.4.1) - Locking doctrine/lexer (1.2.3) - Locking dragonmantank/cron-expression (v3.3.2) - Locking egulias/email-validator (2.1.25) - Locking facade/flare-client-php (1.10.0) - Locking facade/ignition (2.17.6) - Locking facade/ignition-contracts (1.0.2) - Locking fakerphp/faker (v1.20.0) - Locking fideloper/proxy (4.4.2) - Locking filp/whoops (2.14.5) - Locking firebase/php-jwt (v5.5.1) - Locking fruitcake/laravel-cors (v3.0.0) - Locking fruitcake/php-cors (v1.2.0) - Locking graham-campbell/result-type (v1.1.0) - Locking guzzlehttp/guzzle (7.5.0) - Locking guzzlehttp/promises (1.5.2) - Locking guzzlehttp/psr7 (2.4.1) - Locking hamcrest/hamcrest-php (v2.0.1) - Locking laravel/framework (v8.83.25) - Locking laravel/sail (v1.16.2) - Locking laravel/serializable-closure (v1.2.2) - Locking laravel/tinker (v2.7.2) - Locking league/commonmark (2.3.5) - Locking league/config (v1.1.1) - Locking league/flysystem (1.1.10) - Locking league/mime-type-detection (1.11.0) - Locking mockery/mockery (1.5.1) - Locking monolog/monolog (2.8.0) - Locking myclabs/deep-copy (1.11.0) - Locking nesbot/carbon (2.62.1) - Locking nette/schema (v1.2.2) - Locking nette/utils (v3.2.8) - Locking nikic/php-parser (v4.15.1) - Locking nunomaduro/collision (v5.11.0) - Locking opis/closure (3.6.3) - Locking phar-io/manifest (2.0.3) - Locking phar-io/version (3.2.1) - Locking phpoption/phpoption (1.9.0) - Locking phpunit/php-code-coverage (9.2.17) - Locking phpunit/php-file-iterator (3.0.6) - Locking phpunit/php-invoker (3.1.1) - Locking phpunit/php-text-template (2.0.4) - Locking phpunit/php-timer (5.0.3) - Locking phpunit/phpunit (9.5.25) - Locking psr/cache (1.0.1) - Locking psr/container (1.1.2) - Locking psr/event-dispatcher (1.0.0) - Locking psr/http-client (1.0.1) - Locking psr/http-factory (1.0.1) - Locking psr/http-message (1.0.1) - Locking psr/log (1.1.4) - Locking psr/simple-cache (1.0.1) - Locking psy/psysh (v0.11.8) - Locking ralouphie/getallheaders (3.0.3) - Locking ramsey/collection (1.2.2) - Locking ramsey/uuid (4.2.3) - Locking sebastian/cli-parser (1.0.1) - Locking sebastian/code-unit (1.0.8) - Locking sebastian/code-unit-reverse-lookup (2.0.3) - Locking sebastian/comparator (4.0.8) - Locking sebastian/complexity (2.0.2) - Locking sebastian/diff (4.0.4) - Locking sebastian/environment (5.1.4) - Locking sebastian/exporter (4.0.5) - Locking sebastian/global-state (5.0.5) - Locking sebastian/lines-of-code (1.0.3) - Locking sebastian/object-enumerator (4.0.4) - Locking sebastian/object-reflector (2.0.4) - Locking sebastian/recursion-context (4.0.4) - Locking sebastian/resource-operations (3.0.3) - Locking sebastian/type (3.2.0) - Locking sebastian/version (3.0.2) - Locking shopify/shopify-api (v4.1.0) - Locking squizlabs/php_codesniffer (3.7.1) - Locking swiftmailer/swiftmailer (v6.3.0) - Locking symfony/console (v5.4.14) - Locking symfony/css-selector (v5.4.11) - Locking symfony/deprecation-contracts (v2.5.2) - Locking symfony/error-handler (v5.4.14) - Locking symfony/event-dispatcher (v5.4.9) - Locking symfony/event-dispatcher-contracts (v2.5.2) - Locking symfony/finder (v5.4.11) - Locking symfony/http-foundation (v5.4.14) - Locking symfony/http-kernel (v5.4.14) - Locking symfony/mime (v5.4.14) - Locking symfony/polyfill-ctype (v1.26.0) - Locking symfony/polyfill-iconv (v1.26.0) - Locking symfony/polyfill-intl-grapheme (v1.26.0) - Locking symfony/polyfill-intl-idn (v1.26.0) - Locking symfony/polyfill-intl-normalizer (v1.26.0) - Locking symfony/polyfill-mbstring (v1.26.0) - Locking symfony/polyfill-php72 (v1.26.0) - Locking symfony/polyfill-php73 (v1.26.0) - Locking symfony/polyfill-php80 (v1.26.0) - Locking symfony/polyfill-php81 (v1.26.0) - Locking symfony/process (v5.4.11) - Locking symfony/routing (v5.4.11) - Locking symfony/service-contracts (v2.5.2) - Locking symfony/string (v5.4.14) - Locking symfony/translation (v5.4.14) - Locking symfony/translation-contracts (v2.5.2) - Locking symfony/var-dumper (v5.4.14) - Locking theseer/tokenizer (1.2.1) - Locking tijsverkoyen/css-to-inline-styles (2.2.5) - Locking vlucas/phpdotenv (v5.4.1) - Locking voku/portable-ascii (1.6.1) - Locking webmozart/assert (1.11.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 114 installs, 0 updates, 0 removals - Downloading brick/math (0.9.3) - Downloading psr/log (1.1.4) - Downloading psr/cache (1.0.1) - Downloading doctrine/event-manager (1.2.0) - Downloading doctrine/dbal (3.4.5) - Downloading symfony/polyfill-ctype (v1.26.0) - Downloading webmozart/assert (1.11.0) - Downloading dragonmantank/cron-expression (v3.3.2) - Downloading symfony/polyfill-php80 (v1.26.0) - Downloading symfony/polyfill-mbstring (v1.26.0) - Downloading symfony/var-dumper (v5.4.14) - Downloading symfony/polyfill-intl-normalizer (v1.26.0) - Downloading symfony/polyfill-intl-grapheme (v1.26.0) - Downloading symfony/string (v5.4.14) - Downloading psr/container (1.1.2) - Downloading symfony/service-contracts (v2.5.2) - Downloading symfony/polyfill-php73 (v1.26.0) - Downloading symfony/console (v5.4.14) - Downloading monolog/monolog (2.8.0) - Downloading voku/portable-ascii (1.6.1) - Downloading vlucas/phpdotenv (v5.4.1) - Downloading symfony/css-selector (v5.4.11) - Downloading symfony/routing (v5.4.11) - Downloading symfony/process (v5.4.11) - Downloading symfony/polyfill-php72 (v1.26.0) - Downloading symfony/polyfill-intl-idn (v1.26.0) - Downloading symfony/mime (v5.4.14) - Downloading symfony/http-foundation (v5.4.14) - Downloading psr/event-dispatcher (1.0.0) - Downloading symfony/event-dispatcher-contracts (v2.5.2) - Downloading symfony/event-dispatcher (v5.4.9) - Downloading symfony/error-handler (v5.4.14) - Downloading symfony/http-kernel (v5.4.14) - Downloading symfony/finder (v5.4.11) - Downloading symfony/polyfill-iconv (v1.26.0) - Downloading egulias/email-validator (2.1.25) - Downloading swiftmailer/swiftmailer (v6.3.0) - Downloading symfony/polyfill-php81 (v1.26.0) - Downloading ramsey/collection (1.2.2) - Downloading ramsey/uuid (4.2.3) - Downloading psr/simple-cache (1.0.1) - Downloading symfony/translation-contracts (v2.5.2) - Downloading symfony/translation (v5.4.14) - Downloading league/flysystem (1.1.10) - Downloading nette/utils (v3.2.8) - Downloading nette/schema (v1.2.2) - Downloading dflydev/dot-access-data (v3.0.1) - Downloading league/config (v1.1.1) - Downloading laravel/serializable-closure (v1.2.2) - Downloading laravel/framework (v8.83.25) - Downloading facade/ignition-contracts (1.0.2) - Downloading facade/flare-client-php (1.10.0) - Downloading facade/ignition (2.17.6) - Downloading fideloper/proxy (4.4.2) - Downloading fruitcake/php-cors (v1.2.0) - Downloading fruitcake/laravel-cors (v3.0.0) - Downloading ralouphie/getallheaders (3.0.3) - Downloading psr/http-message (1.0.1) - Downloading psr/http-factory (1.0.1) - Downloading guzzlehttp/psr7 (2.4.1) - Downloading laravel/sail (v1.16.2) - Downloading psy/psysh (v0.11.8) - Downloading laravel/tinker (v2.7.2) - Downloading mockery/mockery (1.5.1) - Downloading nunomaduro/collision (v5.11.0) - Downloading sebastian/version (3.0.2) - Downloading sebastian/type (3.2.0) - Downloading sebastian/resource-operations (3.0.3) - Downloading sebastian/recursion-context (4.0.4) - Downloading sebastian/object-reflector (2.0.4) - Downloading sebastian/object-enumerator (4.0.4) - Downloading sebastian/global-state (5.0.5) - Downloading sebastian/exporter (4.0.5) - Downloading sebastian/environment (5.1.4) - Downloading sebastian/diff (4.0.4) - Downloading sebastian/comparator (4.0.8) - Downloading sebastian/code-unit (1.0.8) - Downloading sebastian/cli-parser (1.0.1) - Downloading phpunit/php-timer (5.0.3) - Downloading phpunit/php-text-template (2.0.4) - Downloading phpunit/php-invoker (3.1.1) - Downloading phpunit/php-file-iterator (3.0.6) - Downloading sebastian/lines-of-code (1.0.3) - Downloading sebastian/complexity (2.0.2) - Downloading sebastian/code-unit-reverse-lookup (2.0.3) - Downloading phpunit/php-code-coverage (9.2.17) - Downloading phar-io/version (3.2.1) - Downloading phar-io/manifest (2.0.3) - Downloading phpunit/phpunit (9.5.25) - Downloading psr/http-client (1.0.1) - Downloading guzzlehttp/guzzle (7.5.0) - Downloading firebase/php-jwt (v5.5.1) - Downloading shopify/shopify-api (v4.1.0) - Installing brick/math (0.9.3): Extracting archive - Installing psr/log (1.1.4): Extracting archive - Installing psr/cache (1.0.1): Extracting archive - Installing doctrine/deprecations (v1.0.0): Extracting archive - Installing doctrine/event-manager (1.2.0): Extracting archive - Installing doctrine/cache (2.2.0): Extracting archive - Installing doctrine/dbal (3.4.5): Extracting archive - Installing doctrine/lexer (1.2.3): Extracting archive - Installing symfony/polyfill-ctype (v1.26.0): Extracting archive - Installing webmozart/assert (1.11.0): Extracting archive - Installing dragonmantank/cron-expression (v3.3.2): Extracting archive - Installing symfony/polyfill-php80 (v1.26.0): Extracting archive - Installing symfony/polyfill-mbstring (v1.26.0): Extracting archive - Installing symfony/var-dumper (v5.4.14): Extracting archive - Installing symfony/polyfill-intl-normalizer (v1.26.0): Extracting archive - Installing symfony/polyfill-intl-grapheme (v1.26.0): Extracting archive - Installing symfony/string (v5.4.14): Extracting archive - Installing symfony/deprecation-contracts (v2.5.2): Extracting archive - Installing psr/container (1.1.2): Extracting archive - Installing symfony/service-contracts (v2.5.2): Extracting archive - Installing symfony/polyfill-php73 (v1.26.0): Extracting archive - Installing symfony/console (v5.4.14): Extracting archive - Installing monolog/monolog (2.8.0): Extracting archive - Installing voku/portable-ascii (1.6.1): Extracting archive - Installing phpoption/phpoption (1.9.0): Extracting archive - Installing graham-campbell/result-type (v1.1.0): Extracting archive - Installing vlucas/phpdotenv (v5.4.1): Extracting archive - Installing symfony/css-selector (v5.4.11): Extracting archive - Installing tijsverkoyen/css-to-inline-styles (2.2.5): Extracting archive - Installing symfony/routing (v5.4.11): Extracting archive - Installing symfony/process (v5.4.11): Extracting archive - Installing symfony/polyfill-php72 (v1.26.0): Extracting archive - Installing symfony/polyfill-intl-idn (v1.26.0): Extracting archive - Installing symfony/mime (v5.4.14): Extracting archive - Installing symfony/http-foundation (v5.4.14): Extracting archive - Installing psr/event-dispatcher (1.0.0): Extracting archive - Installing symfony/event-dispatcher-contracts (v2.5.2): Extracting archive - Installing symfony/event-dispatcher (v5.4.9): Extracting archive - Installing symfony/error-handler (v5.4.14): Extracting archive - Installing symfony/http-kernel (v5.4.14): Extracting archive - Installing symfony/finder (v5.4.11): Extracting archive - Installing symfony/polyfill-iconv (v1.26.0): Extracting archive - Installing egulias/email-validator (2.1.25): Extracting archive - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive - Installing symfony/polyfill-php81 (v1.26.0): Extracting archive - Installing ramsey/collection (1.2.2): Extracting archive - Installing ramsey/uuid (4.2.3): Extracting archive - Installing psr/simple-cache (1.0.1): Extracting archive - Installing opis/closure (3.6.3): Extracting archive - Installing symfony/translation-contracts (v2.5.2): Extracting archive - Installing symfony/translation (v5.4.14): Extracting archive - Installing nesbot/carbon (2.62.1): Extracting archive - Installing league/mime-type-detection (1.11.0): Extracting archive - Installing league/flysystem (1.1.10): Extracting archive - Installing nette/utils (v3.2.8): Extracting archive - Installing nette/schema (v1.2.2): Extracting archive - Installing dflydev/dot-access-data (v3.0.1): Extracting archive - Installing league/config (v1.1.1): Extracting archive - Installing league/commonmark (2.3.5): Extracting archive - Installing laravel/serializable-closure (v1.2.2): Extracting archive - Installing doctrine/inflector (2.0.5): Extracting archive - Installing laravel/framework (v8.83.25): Extracting archive - Installing facade/ignition-contracts (1.0.2): Extracting archive - Installing facade/flare-client-php (1.10.0): Extracting archive - Installing facade/ignition (2.17.6): Extracting archive - Installing fakerphp/faker (v1.20.0): Extracting archive - Installing fideloper/proxy (4.4.2): Extracting archive - Installing fruitcake/php-cors (v1.2.0): Extracting archive - Installing fruitcake/laravel-cors (v3.0.0): Extracting archive - Installing guzzlehttp/promises (1.5.2): Extracting archive - Installing ralouphie/getallheaders (3.0.3): Extracting archive - Installing psr/http-message (1.0.1): Extracting archive - Installing psr/http-factory (1.0.1): Extracting archive - Installing guzzlehttp/psr7 (2.4.1): Extracting archive - Installing laravel/sail (v1.16.2): Extracting archive - Installing nikic/php-parser (v4.15.1): Extracting archive - Installing psy/psysh (v0.11.8): Extracting archive - Installing laravel/tinker (v2.7.2): Extracting archive - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive - Installing mockery/mockery (1.5.1): Extracting archive - Installing filp/whoops (2.14.5): Extracting archive - Installing nunomaduro/collision (v5.11.0): Extracting archive - Installing sebastian/version (3.0.2): Extracting archive - Installing sebastian/type (3.2.0): Extracting archive - Installing sebastian/resource-operations (3.0.3): Extracting archive - Installing sebastian/recursion-context (4.0.4): Extracting archive - Installing sebastian/object-reflector (2.0.4): Extracting archive - Installing sebastian/object-enumerator (4.0.4): Extracting archive - Installing sebastian/global-state (5.0.5): Extracting archive - Installing sebastian/exporter (4.0.5): Extracting archive - Installing sebastian/environment (5.1.4): Extracting archive - Installing sebastian/diff (4.0.4): Extracting archive - Installing sebastian/comparator (4.0.8): Extracting archive - Installing sebastian/code-unit (1.0.8): Extracting archive - Installing sebastian/cli-parser (1.0.1): Extracting archive - Installing phpunit/php-timer (5.0.3): Extracting archive - Installing phpunit/php-text-template (2.0.4): Extracting archive - Installing theseer/tokenizer (1.2.1): Extracting archive - Installing sebastian/lines-of-code (1.0.3): Extracting archive - Installing sebastian/complexity (2.0.2): Extracting archive - Installing sebastian/code-unit-reverse-lookup (2.0.3): Extracting archive - Installing phpunit/php-code-coverage (9.2.17): Extracting archive - Installing phar-io/version (3.2.1): Extracting archive - Installing phar-io/manifest (2.0.3): Extracting archive - Installing myclabs/deep-copy (1.11.0): Extracting archive - Installing doctrine/instantiator (1.4.1): Extracting archive - Installing phpunit/phpunit (9.5.25): Extracting archive - Installing psr/http-client (1.0.1): Extracting archive - Installing guzzlehttp/guzzle (7.5.0): Extracting archive - Installing firebase/php-jwt (v5.5.1): Extracting archive - Installing shopify/shopify-api (v4.1.0): Extracting archive - Installing squizlabs/php_codesniffer (3.7.1): Extracting archive 68 package suggestions were added by new dependencies, use `composer suggest` to see details. Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead. Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Discovered Package: facade/ignition Discovered Package: fideloper/proxy Discovered Package: fruitcake/laravel-cors Discovered Package: laravel/sail Discovered Package: laravel/tinker Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Package manifest generated successfully. 81 packages you are using are looking for funding. Use the `composer fund` command to find out more! PS E:\wwwroot\shopify-app\learn-app\web> ls 目录: E:\wwwroot\shopify-app\learn-app\web Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2022/10/14 14:54 bootstrap d----- 2022/10/14 14:54 database d----- 2022/10/14 14:54 frontend d----- 2022/10/14 14:54 public d----- 2022/10/14 14:54 resources d----- 2022/10/14 14:54 routes d----- 2022/10/14 14:54 storage d----- 2022/10/14 15:26 vendor -a---- 2022/10/14 14:50 261 .env -a---- 2022/10/14 14:50 261 .env.example -a---- 2022/10/14 14:50 370 .env.testing -a---- 2022/10/14 14:50 1743 artisan -a---- 2022/10/14 14:50 2282 composer.json -a---- 2022/10/14 15:26 303790 composer.lock -a---- 2022/10/14 14:50 469 entrypoint.sh -a---- 2022/10/14 14:50 898 nginx.conf -a---- 2022/10/14 14:50 1233 phpunit.xml -a---- 2022/10/14 14:50 584 server.php -a---- 2022/10/14 14:50 80 shopify.web.toml PS E:\wwwroot\shopify-app\learn-app\web> touch storage/db.sqlite touch : 无法将“touch”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正 确,然后再试一次。 所在位置 行:1 字符: 1 + touch storage/db.sqlite + ~~~~~ + CategoryInfo : ObjectNotFound: (touch:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS E:\wwwroot\shopify-app\learn-app\web> php artisan key:generate PS E:\wwwroot\shopify-app\learn-app\web> ls 目录: E:\wwwroot\shopify-app\learn-app\web Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2022/10/14 14:54 app d----- 2022/10/14 14:54 bootstrap d----- 2022/10/14 14:54 config d----- 2022/10/14 14:54 database d----- 2022/10/14 14:54 frontend d----- 2022/10/14 14:54 public d----- 2022/10/14 14:54 resources d----- 2022/10/14 14:54 routes d----- 2022/10/14 15:42 storage d----- 2022/10/14 15:26 vendor -a---- 2022/10/14 15:44 337 .env -a---- 2022/10/14 14:50 261 .env.example -a---- 2022/10/14 14:50 370 .env.testing -a---- 2022/10/14 14:50 1743 artisan -a---- 2022/10/14 14:50 2282 composer.json -a---- 2022/10/14 15:26 303790 composer.lock -a---- 2022/10/14 14:50 469 entrypoint.sh -a---- 2022/10/14 14:50 898 nginx.conf -a---- 2022/10/14 14:50 1233 phpunit.xml -a---- 2022/10/14 14:50 584 server.php -a---- 2022/10/14 14:50 80 shopify.web.toml
5、在您的数据库中创建必要的 Shopify 表,报错:Illuminate\Database\QueryException could not find driver (SQL: PRAGMA foreign_keys = ON;)。如图5
PS E:\wwwroot\shopify-app\learn-app\web> php artisan migrate Illuminate\Database\QueryException could not find driver (SQL: PRAGMA foreign_keys = ON;) at E:\wwwroot\shopify-app\learn-app\web\vendor\laravel\framework\src\Illuminate\Database\Connection.php:712 708▕ // If an exception occurs when attempting to run a query, we'll format the error 709▕ // message to include the bindings with SQL, which will make this exception a 710▕ // lot more helpful to the developer instead of just the database's errors. 711▕ catch (Exception $e) { ➜ 712▕ throw new QueryException( 713▕ $query, $this->prepareBindings($bindings), $e 714▕ ); 715▕ } 716▕ } 1 E:\wwwroot\shopify-app\learn-app\web\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDOException::("could not find driver") 2 E:\wwwroot\shopify-app\learn-app\web\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDO::__construct("sqlite:E:\wwwroot\shopify-app\learn-app\web\storage\db.sqlite", []) PS E:\wwwroot\shopify-app\learn-app\web>
6、编辑 php.ini,extension=pdo_sqlite。重启 PHP 。查看数据库,表新建成功。如图6
PS E:\wwwroot\shopify-app\learn-app\web> php artisan migrate Migration table created successfully. Migrating: 2019_08_19_000000_create_failed_jobs_table Migrated: 2019_08_19_000000_create_failed_jobs_table (249.14ms) Migrating: 2021_05_03_050717_create_sessions_table Migrated: 2021_05_03_050717_create_sessions_table (188.38ms) Migrating: 2021_05_05_071311_add_scope_expires_access_token_to_sessions Migrated: 2021_05_05_071311_add_scope_expires_access_token_to_sessions (315.43ms) Migrating: 2021_05_11_151158_add_online_access_info_to_sessions Migrated: 2021_05_11_151158_add_online_access_info_to_sessions (822.19ms) Migrating: 2021_05_17_152611_change_sessions_user_id_type Migrated: 2021_05_17_152611_change_sessions_user_id_type (1,303.13ms) PS E:\wwwroot\shopify-app\learn-app\web>
7、要为您的应用启动本地服务器,请运行以下命令。如图7
PS E:\wwwroot\shopify-app\learn-app> yarn dev yarn run v1.22.15 $ shopify app dev ✔ Dependencies installed To run this command, log in to Shopify Partners. 👉 Press any key to open the login page on your browser ✔ Logged in. Looks like this is the first time you're running dev for this project. Configure your preferences by answering a few questions. ✔ App Name · learn-app ✅ Success! learn-app has been created on your Partners account. ✔ Using your default dev store (shuijingwanwq-development) to preview your project. ✅ Success! Converted shuijingwanwq-development.myshopify.com to a Test store. To make your local code accessible to your dev store, you need to use a Shopify-trusted tunneling service called ngrok. To sign up and get an auth token: https://dashboard.ngrok.com/get-started/your-authtoken (https://dashboard.ngrok.com/get-started/your-authtoken) ✔ Enter your ngrok token. · ************************************************* ✅ Success! The tunnel is running and you can now view your app. For your convenience, we've given your app a default URL: https://4a94-66-175-216-239.ngrok.io. You can update your app's URL anytime in the Partners Dashboard (https://partners.shopify.com/2442779/apps/12958171137/edit). But once your app is live, updating its URL will disrupt merchant access. Shareable app URL https://4a94-66-175-216-239.ngrok.io?shop=shuijingwanwq-development.myshopify.com&host=c2h1aWppbmd3YW53cS1kZXZlbG9wbWVudC5teXNob3BpZnkuY29tL2FkbWlu frontend | frontend | > dev frontend | > vite frontend | frontend | frontend | vite v2.9.15 dev server running at: frontend | frontend | > Network: http://192.168.56.1:57522/ frontend | > Network: http://192.168.10.1:57522/ frontend | > Network: http://192.168.89.86:57522/ frontend | > Local: http://localhost:57522/ frontend | > Network: http://172.17.176.1:57522/ frontend | frontend | ready in 2602ms. frontend | backend | > Composer\Config::disableProcessTimeout backend | > php artisan serve backend | Starting Laravel development server: http://127.0.0.1:57518 backend | [Fri Oct 14 16:52:21 2022] PHP 7.4.27 Development Server (http://127.0.0.1:57518) started
8、期间需要输入 ngrok 的 Authtoken。如图8
9、启动 Laravel 开发服务器:http://127.0.0.1:57518 。在浏览器中打开。报错:Argument 1 passed to Shopify\Utils::sanitizeShopDomain() must be of the type string, null given, called in E:\wwwroot\shopify-app\learn-app\web\app\Lib\AuthRedirection.php on line 17 。原因在于未在网址中带上参数:shop。如图9
10、在开发商店中安装您的应用。打开 Shareable app URL:https://4a94-66-175-216-239.ngrok.io?shop=shuijingwanwq-development.myshopify.com&host=c2h1aWppbmd3YW53cS1kZXZlbG9wbWVudC5teXNob3BpZnkuY29tL2FkbWlu 。打开 URL 时,系统会提示您在开发商店中安装应用程序。单击安装应用程序以在商店中安装应用程序。如图10
11、安装过程中报错:Shopify\Exception\CookieNotFoundException Could not find the current session id in the cookies。如图11
12、重新从第 7 步骤开始执行,跳过第 9 步骤。您现在有一个安装了新应用程序的开发商店。如图12
近期评论