Composer – 永夜 https://www.shuijingwanwq.com 没有不值得去解决的问题,也没有不值得去学习的技术! Thu, 21 May 2026 11:15:07 +0000 zh-Hans hourly 1 https://wordpress.org/?v=7.0 在 WSL-Ubuntu 中 Docker 下安装 Hyperf https://www.shuijingwanwq.com/2026/03/20/9355/ https://www.shuijingwanwq.com/2026/03/20/9355/#respond Fri, 20 Mar 2026 03:32:36 +0000 https://www.shuijingwanwq.com/?p=9355 浏览量: 151

1、第一步:在 WSL 里创建本地项目目录(比如 ~/wwwroot/hyperf-skeleton)



ubuntu@DESKTOP-H4MGQIU:~/wwwroot$ mkdir -p ~/wwwroot/hyperf-skeleton


2、修改挂载目录,适配本地目录的路径。参考:Hyperf 官方文档 Docker 下开发



ubuntu@DESKTOP-H4MGQIU:~/wwwroot$ docker run --name hyperf \
-v ~/wwwroot/hyperf-skeleton:/data/project \
-w /data/project \
-p 9501:9501 -it \
--privileged -u root \
--entrypoint /bin/sh \
hyperf/hyperf:8.1-alpine-v3.18-swoole
Unable to find image 'hyperf/hyperf:8.1-alpine-v3.18-swoole' locally
8.1-alpine-v3.18-swoole: Pulling from hyperf/hyperf
5715dfbf9dd7: Pull complete
bfa571bff938: Pull complete
58de83433912: Pull complete
44cf07d57ee4: Pull complete
471a4d85c85c: Download complete
Digest: sha256:3cbda08f3892507d760d31bba8b68aeb4b916333055bbf05cf46ea18c67fc935
Status: Downloaded newer image for hyperf/hyperf:8.1-alpine-v3.18-swoole
/data/project #


3、在容器内创建项目 ,创建项目失败,报错:Your requirements could not be resolved to an installable set of packages.。如图1

在容器内创建项目 ,创建项目失败,报错:Your requirements could not be resolved to an installable set of packages.


/data/project # composer create-project hyperf/hyperf-skeleton
Creating a "hyperf/hyperf-skeleton" project at "./hyperf-skeleton"
Installing hyperf/hyperf-skeleton (v3.1.3)
<ul>
 	<li>Downloading hyperf/hyperf-skeleton (v3.1.3)</li>
 	<li>Installing hyperf/hyperf-skeleton (v3.1.3): Extracting archive
Created project in /data/project/hyperf-skeleton</li>
</ul>
<blockquote>@php -r "file_exists('.env') || copy('.env.example', '.env');"
Installer\Script::install
Setting up optional packages
Setup data and cache dir
Removing installer development dependencies</blockquote>
What time zone do you want to setup ?
[n] Default time zone for php.ini
Make your selection or type a time zone name, like Asia/Shanghai (n):
Asia/Shanghai

Do you want to use Database (MySQL Client) ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (yes): y
<ul>
 	<li>Adding package hyperf/database (~3.1.0)</li>
 	<li>Adding package hyperf/db-connection (~3.1.0)

Do you want to use Redis Client ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (yes): y</li>
 	<li>Adding package hyperf/redis (~3.1.0)</li>
 	<li>Copying config/autoload/redis.php

Which RPC protocol do you want to use ?
[1] JSON RPC with Service Governance
[2] JSON RPC
[3] gRPC
[n] None of the above
Make your selection or type a composer package name and version (n): n

Which config center do you want to use ?
[1] Apollo
[2] Aliyun ACM
[3] ETCD
[4] Nacos
[n] None of the above
Make your selection or type a composer package name and version (n): n

Do you want to use hyperf/constants component ?
[y] yes
[n] None of the above
Make your selection (n): y</li>
 	<li>Adding package hyperf/constants (~3.1.0)</li>
 	<li>Copying app/Constants/ErrorCode.php</li>
 	<li>Copying app/Exception/BusinessException.php

Do you want to use hyperf/async-queue component ? (A simple redis queue component)
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): y</li>
 	<li>Adding package hyperf/async-queue (~3.1.0)</li>
 	<li>Copying config/autoload/async_queue.php</li>
 	<li>Copying app/Process/AsyncQueueConsumer.php</li>
 	<li>Copying app/Listener/QueueHandleListener.php</li>
 	<li>Copying config/autoload/redis.php

Do you want to use hyperf/amqp component ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): n

Do you want to use hyperf/model-cache component ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): n

Do you want to use hyperf/elasticsearch component ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): n

Do you want to use hyperf/tracer component ? (An open tracing protocol component, adapte with Zipkin etc.)
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): n

Do you want to use pestphp/pest component ? (Pest is a testing framework with a focus on simplicity,
meticulously designed to bring back the joy of testing in PHP.)
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): y</li>
 	<li>Adding package pestphp/pest (^2.34)</li>
 	<li>Copying test/Feature/ExampleTest.php</li>
 	<li>Copying test/Unit/ExampleTest.php</li>
 	<li>Copying test/Pest.php</li>
 	<li>Copying test/TestCase.php
Remove installer
Removing composer.lock from .gitignore
Removing Expressive installer classes, configuration, tests and docs
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
<ul>
 	<li>Root composer.json requires pestphp/pest ^2.34 -&gt; satisfiable by pestphp/pest[v2.34.0, …, 2.x-dev].</li>
 	<li>brianium/paratest[v7.9.0, …, v7.11.2] require php ~8.3.0 || ~8.4.0 -&gt; your php version (8.1.27) does not satisfy that requirement.</li>
 	<li>brianium/paratest[v7.12.0, …, 7.x-dev] require php ~8.3.0 || ~8.4.0 || ~8.5.0 -&gt; your php version (8.1.27) does not satisfy that requirement.</li>
 	<li>brianium/paratest[v7.4.3, …, v7.5.7] require php ~8.2.0 || ~8.3.0 -&gt; your php version (8.1.27) does not satisfy that requirement.</li>
 	<li>brianium/paratest[v7.4.8, …, v7.8.4] require php ~8.2.0 || ~8.3.0 || ~8.4.0 -&gt; your php version (8.1.27) does not satisfy that requirement.</li>
 	<li>brianium/paratest[v7.8.5, …, 7.8.x-dev] require php ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 -&gt; your php version (8.1.27) does not satisfy that requirement.</li>
 	<li>pestphp/pest v2.34.0 conflicts with phpunit/phpunit 10.5.63.</li>
 	<li>pestphp/pest v2.34.0 conflicts with phpunit/phpunit 10.5.x-dev.</li>
 	<li>pestphp/pest v2.34.0 requires phpunit/phpunit ^10.5.10 -&gt; satisfiable by phpunit/phpunit[10.5.62, 10.5.63, 10.5.x-dev].</li>
 	<li>pestphp/pest v2.34.3 requires brianium/paratest ^7.4.3 -&gt; satisfiable by brianium/paratest[v7.4.3, …, 7.x-dev].</li>
 	<li>pestphp/pest[v2.36.1, …, 2.x-dev] require php ^8.2.0 -&gt; your php version (8.1.27) does not satisfy that requirement.</li>
 	<li>Conclusion: don't install pestphp/pest v2.34.1 (conflict analysis result)</li>
 	<li>Conclusion: don't install pestphp/pest v2.34.2 (conflict analysis result)</li>
 	<li>Conclusion: don't install pestphp/pest v2.34.4 (conflict analysis result)</li>
 	<li>Conclusion: don't install pestphp/pest v2.34.5 (conflict analysis result)</li>
 	<li>Conclusion: don't install pestphp/pest v2.34.6 (conflict analysis result)</li>
 	<li>Conclusion: don't install pestphp/pest v2.34.9 (conflict analysis result)</li>
 	<li>Conclusion: don't install pestphp/pest v2.35.0 (conflict analysis result)</li>
 	<li>Conclusion: don't install pestphp/pest v2.35.1 (conflict analysis result)</li>
 	<li>Conclusion: don't install pestphp/pest v2.36.0 (conflict analysis result)</li>
</ul>
</li>
</ul>
/data/project #


4、报错核心原因如下:
PHP 版本不匹配:容器里的 PHP 是 8.1.27,但 Pest(测试框架)的新版本要求 PHP ≥ 8.2,我的 PHP 8.1 满足不了;
依赖连锁冲突:Pest 依赖的 brianium/paratest、phpunit/phpunit 等组件,也要求更高版本的 PHP,最终导致 Composer 无法解析出一套能安装的依赖包。

5、最快解决方法(放弃安装 Pest,先跑通项目),退出当前失败的安装流程:重新执行创建项目命令(跳过 Pest),选择 n。提示: Project directory “/data/project/hyperf-skeleton” is not empty.。在容器的 /data/project 目录下,执行清空命令:rm -rf ./* ./.??* 。如图2

提示: Project directory "/data/project/hyperf-skeleton" is not empty.。在容器的 /data/project 目录下,执行清空命令:rm -rf ./* ./.??*


/data/project # composer create-project hyperf/hyperf-skeleton
Creating a "hyperf/hyperf-skeleton" project at "./hyperf-skeleton"

In CreateProjectCommand.php line 368:

Project directory "/data/project/hyperf-skeleton" is not empty.

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--no-security-blocking] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--ask] [--] [<package> [<directory> [<version>]]]



6、在容器内创建项目 在 遇见 pestphp/pest 时,选择 n,创建项目成功。



/data/project # composer create-project hyperf/hyperf-skeleton
Creating a "hyperf/hyperf-skeleton" project at "./hyperf-skeleton"
Installing hyperf/hyperf-skeleton (v3.1.3)
<ul>
 	<li>Installing hyperf/hyperf-skeleton (v3.1.3): Extracting archive
Created project in /data/project/hyperf-skeleton</li>
</ul>
<blockquote>@php -r "file_exists('.env') || copy('.env.example', '.env');"
Installer\Script::install
Setting up optional packages
Setup data and cache dir
Removing installer development dependencies</blockquote>
What time zone do you want to setup ?
[n] Default time zone for php.ini
Make your selection or type a time zone name, like Asia/Shanghai (n):
Asia/Shanghai

Do you want to use Database (MySQL Client) ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (yes): y
<ul>
 	<li>Adding package hyperf/database (~3.1.0)</li>
 	<li>Adding package hyperf/db-connection (~3.1.0)

Do you want to use Redis Client ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (yes): y</li>
 	<li>Adding package hyperf/redis (~3.1.0)</li>
 	<li>Copying config/autoload/redis.php

Which RPC protocol do you want to use ?
[1] JSON RPC with Service Governance
[2] JSON RPC
[3] gRPC
[n] None of the above
Make your selection or type a composer package name and version (n): n

Which config center do you want to use ?
[1] Apollo
[2] Aliyun ACM
[3] ETCD
[4] Nacos
[n] None of the above
Make your selection or type a composer package name and version (n): n

Do you want to use hyperf/constants component ?
[y] yes
[n] None of the above
Make your selection (n): y</li>
 	<li>Adding package hyperf/constants (~3.1.0)</li>
 	<li>Copying app/Constants/ErrorCode.php</li>
 	<li>Copying app/Exception/BusinessException.php

Do you want to use hyperf/async-queue component ? (A simple redis queue component)
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): y</li>
 	<li>Adding package hyperf/async-queue (~3.1.0)</li>
 	<li>Copying config/autoload/async_queue.php</li>
 	<li>Copying app/Process/AsyncQueueConsumer.php</li>
 	<li>Copying app/Listener/QueueHandleListener.php</li>
 	<li>Copying config/autoload/redis.php

Do you want to use hyperf/amqp component ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): n

Do you want to use hyperf/model-cache component ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): n

Do you want to use hyperf/elasticsearch component ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): n

Do you want to use hyperf/tracer component ? (An open tracing protocol component, adapte with Zipkin etc.)
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): n

Do you want to use pestphp/pest component ? (Pest is a testing framework with a focus on simplicity,
meticulously designed to bring back the joy of testing in PHP.)
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (n): n
Remove installer
Removing composer.lock from .gitignore
Removing Expressive installer classes, configuration, tests and docs
Loading composer repositories with package information
Updating dependencies
Lock file operations: 135 installs, 0 updates, 0 removals</li>
 	<li>Locking carbonphp/carbon-doctrine-types (3.2.0)</li>
 	<li>Locking clue/ndjson-react (v1.3.0)</li>
 	<li>Locking composer/pcre (3.3.2)</li>
 	<li>Locking composer/semver (3.4.4)</li>
 	<li>Locking composer/xdebug-handler (3.0.5)</li>
 	<li>Locking doctrine/inflector (2.1.0)</li>
 	<li>Locking doctrine/instantiator (1.5.0)</li>
 	<li>Locking evenement/evenement (v3.0.2)</li>
 	<li>Locking fidry/cpu-core-counter (1.3.0)</li>
 	<li>Locking fig/http-message-util (1.1.5)</li>
 	<li>Locking friendsofphp/php-cs-fixer (v3.94.2)</li>
 	<li>Locking graham-campbell/result-type (v1.1.4)</li>
 	<li>Locking guzzlehttp/guzzle (7.10.0)</li>
 	<li>Locking guzzlehttp/promises (2.3.0)</li>
 	<li>Locking guzzlehttp/psr7 (2.9.0)</li>
 	<li>Locking hamcrest/hamcrest-php (v2.1.1)</li>
 	<li>Locking hyperf/async-queue (v3.1.64)</li>
 	<li>Locking hyperf/cache (v3.1.67)</li>
 	<li>Locking hyperf/code-parser (v3.1.63)</li>
 	<li>Locking hyperf/codec (v3.1.63)</li>
 	<li>Locking hyperf/collection (v3.1.64)</li>
 	<li>Locking hyperf/command (v3.1.64)</li>
 	<li>Locking hyperf/conditionable (v3.1.63)</li>
 	<li>Locking hyperf/config (v3.1.63)</li>
 	<li>Locking hyperf/constants (v3.1.63)</li>
 	<li>Locking hyperf/context (v3.1.63)</li>
 	<li>Locking hyperf/contract (v3.1.63)</li>
 	<li>Locking hyperf/coordinator (v3.1.63)</li>
 	<li>Locking hyperf/coroutine (v3.1.65)</li>
 	<li>Locking hyperf/database (v3.1.67)</li>
 	<li>Locking hyperf/db-connection (v3.1.66)</li>
 	<li>Locking hyperf/devtool (v3.1.66)</li>
 	<li>Locking hyperf/di (v3.1.67)</li>
 	<li>Locking hyperf/dispatcher (v3.1.63)</li>
 	<li>Locking hyperf/engine (v2.15.0)</li>
 	<li>Locking hyperf/engine-contract (v1.14.0)</li>
 	<li>Locking hyperf/event (v3.1.63)</li>
 	<li>Locking hyperf/exception-handler (v3.1.63)</li>
 	<li>Locking hyperf/framework (v3.1.63)</li>
 	<li>Locking hyperf/guzzle (v3.1.66)</li>
 	<li>Locking hyperf/http-message (v3.1.65)</li>
 	<li>Locking hyperf/http-server (v3.1.65)</li>
 	<li>Locking hyperf/laminas-mime (v3.0.0)</li>
 	<li>Locking hyperf/logger (v3.1.63)</li>
 	<li>Locking hyperf/macroable (v3.1.63)</li>
 	<li>Locking hyperf/memory (v3.1.63)</li>
 	<li>Locking hyperf/model-listener (v3.1.63)</li>
 	<li>Locking hyperf/pipeline (v3.1.63)</li>
 	<li>Locking hyperf/pool (v3.1.66)</li>
 	<li>Locking hyperf/process (v3.1.63)</li>
 	<li>Locking hyperf/redis (v3.1.66)</li>
 	<li>Locking hyperf/serializer (v3.1.63)</li>
 	<li>Locking hyperf/server (v3.1.63)</li>
 	<li>Locking hyperf/stdlib (v3.1.63)</li>
 	<li>Locking hyperf/stringable (v3.1.65)</li>
 	<li>Locking hyperf/support (v3.1.65)</li>
 	<li>Locking hyperf/tappable (v3.1.63)</li>
 	<li>Locking hyperf/testing (v3.1.63)</li>
 	<li>Locking laminas/laminas-stdlib (3.20.0)</li>
 	<li>Locking mockery/mockery (1.6.12)</li>
 	<li>Locking monolog/monolog (3.10.0)</li>
 	<li>Locking myclabs/deep-copy (1.13.4)</li>
 	<li>Locking nesbot/carbon (2.73.0)</li>
 	<li>Locking nikic/fast-route (v1.3.0)</li>
 	<li>Locking nikic/php-parser (v4.19.5)</li>
 	<li>Locking phar-io/manifest (2.0.4)</li>
 	<li>Locking phar-io/version (3.2.1)</li>
 	<li>Locking php-di/phpdoc-reader (2.2.1)</li>
 	<li>Locking phpoption/phpoption (1.9.5)</li>
 	<li>Locking phpstan/phpstan (1.12.33)</li>
 	<li>Locking phpunit/php-code-coverage (10.1.16)</li>
 	<li>Locking phpunit/php-file-iterator (4.1.0)</li>
 	<li>Locking phpunit/php-invoker (4.0.0)</li>
 	<li>Locking phpunit/php-text-template (3.0.1)</li>
 	<li>Locking phpunit/php-timer (6.0.0)</li>
 	<li>Locking phpunit/phpunit (10.5.63)</li>
 	<li>Locking psr/clock (1.0.0)</li>
 	<li>Locking psr/container (2.0.2)</li>
 	<li>Locking psr/event-dispatcher (1.0.0)</li>
 	<li>Locking psr/http-client (1.0.3)</li>
 	<li>Locking psr/http-factory (1.1.0)</li>
 	<li>Locking psr/http-message (2.0)</li>
 	<li>Locking psr/http-server-handler (1.0.2)</li>
 	<li>Locking psr/http-server-middleware (1.0.2)</li>
 	<li>Locking psr/log (3.0.2)</li>
 	<li>Locking psr/simple-cache (3.0.0)</li>
 	<li>Locking ralouphie/getallheaders (3.0.3)</li>
 	<li>Locking react/cache (v1.2.0)</li>
 	<li>Locking react/child-process (v0.6.7)</li>
 	<li>Locking react/dns (v1.14.0)</li>
 	<li>Locking react/event-loop (v1.6.0)</li>
 	<li>Locking react/promise (v3.3.0)</li>
 	<li>Locking react/socket (v1.17.0)</li>
 	<li>Locking react/stream (v1.4.0)</li>
 	<li>Locking sebastian/cli-parser (2.0.1)</li>
 	<li>Locking sebastian/code-unit (2.0.0)</li>
 	<li>Locking sebastian/code-unit-reverse-lookup (3.0.0)</li>
 	<li>Locking sebastian/comparator (5.0.5)</li>
 	<li>Locking sebastian/complexity (3.2.0)</li>
 	<li>Locking sebastian/diff (5.1.1)</li>
 	<li>Locking sebastian/environment (6.1.0)</li>
 	<li>Locking sebastian/exporter (5.1.4)</li>
 	<li>Locking sebastian/global-state (6.0.2)</li>
 	<li>Locking sebastian/lines-of-code (2.0.2)</li>
 	<li>Locking sebastian/object-enumerator (5.0.0)</li>
 	<li>Locking sebastian/object-reflector (3.0.0)</li>
 	<li>Locking sebastian/recursion-context (5.0.1)</li>
 	<li>Locking sebastian/type (4.0.0)</li>
 	<li>Locking sebastian/version (4.0.1)</li>
 	<li>Locking swoole/ide-helper (5.1.8)</li>
 	<li>Locking swow/psr7-plus (v1.1.2)</li>
 	<li>Locking symfony/console (v6.4.35)</li>
 	<li>Locking symfony/deprecation-contracts (v3.6.0)</li>
 	<li>Locking symfony/event-dispatcher (v6.4.32)</li>
 	<li>Locking symfony/event-dispatcher-contracts (v3.6.0)</li>
 	<li>Locking symfony/filesystem (v6.4.34)</li>
 	<li>Locking symfony/finder (v6.4.34)</li>
 	<li>Locking symfony/http-foundation (v6.4.35)</li>
 	<li>Locking symfony/options-resolver (v6.4.30)</li>
 	<li>Locking symfony/polyfill-ctype (v1.33.0)</li>
 	<li>Locking symfony/polyfill-intl-grapheme (v1.33.0)</li>
 	<li>Locking symfony/polyfill-intl-normalizer (v1.33.0)</li>
 	<li>Locking symfony/polyfill-mbstring (v1.33.0)</li>
 	<li>Locking symfony/polyfill-php80 (v1.33.0)</li>
 	<li>Locking symfony/polyfill-php81 (v1.33.0)</li>
 	<li>Locking symfony/polyfill-php83 (v1.33.0)</li>
 	<li>Locking symfony/polyfill-php84 (v1.33.0)</li>
 	<li>Locking symfony/process (v6.4.33)</li>
 	<li>Locking symfony/service-contracts (v3.6.1)</li>
 	<li>Locking symfony/stopwatch (v6.4.24)</li>
 	<li>Locking symfony/string (v6.4.34)</li>
 	<li>Locking symfony/translation (v6.4.34)</li>
 	<li>Locking symfony/translation-contracts (v3.6.1)</li>
 	<li>Locking theseer/tokenizer (1.3.1)</li>
 	<li>Locking vlucas/phpdotenv (v5.6.3)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 135 installs, 0 updates, 0 removals</li>
 	<li>Downloading composer/pcre (3.3.2)</li>
 	<li>Downloading doctrine/inflector (2.1.0)</li>
 	<li>Downloading doctrine/instantiator (1.5.0)</li>
 	<li>Downloading symfony/deprecation-contracts (v3.6.0)</li>
 	<li>Downloading psr/container (2.0.2)</li>
 	<li>Downloading symfony/service-contracts (v3.6.1)</li>
 	<li>Downloading symfony/stopwatch (v6.4.24)</li>
 	<li>Downloading symfony/process (v6.4.33)</li>
 	<li>Downloading symfony/polyfill-php84 (v1.33.0)</li>
 	<li>Downloading symfony/polyfill-php81 (v1.33.0)</li>
 	<li>Downloading symfony/polyfill-php80 (v1.33.0)</li>
 	<li>Downloading symfony/polyfill-mbstring (v1.33.0)</li>
 	<li>Downloading symfony/options-resolver (v6.4.30)</li>
 	<li>Downloading symfony/finder (v6.4.34)</li>
 	<li>Downloading symfony/polyfill-ctype (v1.33.0)</li>
 	<li>Downloading symfony/filesystem (v6.4.34)</li>
 	<li>Downloading psr/event-dispatcher (1.0.0)</li>
 	<li>Downloading symfony/event-dispatcher-contracts (v3.6.0)</li>
 	<li>Downloading symfony/event-dispatcher (v6.4.32)</li>
 	<li>Downloading symfony/polyfill-intl-normalizer (v1.33.0)</li>
 	<li>Downloading symfony/polyfill-intl-grapheme (v1.33.0)</li>
 	<li>Downloading symfony/string (v6.4.34)</li>
 	<li>Downloading symfony/console (v6.4.35)</li>
 	<li>Downloading sebastian/diff (5.1.1)</li>
 	<li>Downloading react/event-loop (v1.6.0)</li>
 	<li>Downloading evenement/evenement (v3.0.2)</li>
 	<li>Downloading react/stream (v1.4.0)</li>
 	<li>Downloading react/promise (v3.3.0)</li>
 	<li>Downloading react/cache (v1.2.0)</li>
 	<li>Downloading react/dns (v1.14.0)</li>
 	<li>Downloading react/socket (v1.17.0)</li>
 	<li>Downloading react/child-process (v0.6.7)</li>
 	<li>Downloading fidry/cpu-core-counter (1.3.0)</li>
 	<li>Downloading psr/log (3.0.2)</li>
 	<li>Downloading composer/xdebug-handler (3.0.5)</li>
 	<li>Downloading composer/semver (3.4.4)</li>
 	<li>Downloading clue/ndjson-react (v1.3.0)</li>
 	<li>Downloading friendsofphp/php-cs-fixer (v3.94.2)</li>
 	<li>Downloading guzzlehttp/promises (2.3.0)</li>
 	<li>Downloading ralouphie/getallheaders (3.0.3)</li>
 	<li>Downloading psr/http-message (2.0)</li>
 	<li>Downloading psr/http-factory (1.1.0)</li>
 	<li>Downloading guzzlehttp/psr7 (2.9.0)</li>
 	<li>Downloading hyperf/tappable (v3.1.63)</li>
 	<li>Downloading hyperf/macroable (v3.1.63)</li>
 	<li>Downloading hyperf/conditionable (v3.1.63)</li>
 	<li>Downloading hyperf/stringable (v3.1.65)</li>
 	<li>Downloading hyperf/contract (v3.1.63)</li>
 	<li>Downloading hyperf/collection (v3.1.64)</li>
 	<li>Downloading hyperf/engine-contract (v1.14.0)</li>
 	<li>Downloading hyperf/engine (v2.15.0)</li>
 	<li>Downloading hyperf/context (v3.1.63)</li>
 	<li>Downloading hyperf/coroutine (v3.1.65)</li>
 	<li>Downloading hyperf/support (v3.1.65)</li>
 	<li>Downloading phpoption/phpoption (1.9.5)</li>
 	<li>Downloading graham-campbell/result-type (v1.1.4)</li>
 	<li>Downloading vlucas/phpdotenv (v5.6.3)</li>
 	<li>Downloading php-di/phpdoc-reader (2.2.1)</li>
 	<li>Downloading nikic/php-parser (v4.19.5)</li>
 	<li>Downloading hyperf/stdlib (v3.1.63)</li>
 	<li>Downloading hyperf/pipeline (v3.1.63)</li>
 	<li>Downloading hyperf/code-parser (v3.1.63)</li>
 	<li>Downloading hyperf/di (v3.1.67)</li>
 	<li>Downloading hyperf/coordinator (v3.1.63)</li>
 	<li>Downloading hyperf/command (v3.1.64)</li>
 	<li>Downloading hyperf/codec (v3.1.63)</li>
 	<li>Downloading hyperf/async-queue (v3.1.64)</li>
 	<li>Downloading psr/simple-cache (3.0.0)</li>
 	<li>Downloading hyperf/cache (v3.1.67)</li>
 	<li>Downloading hyperf/config (v3.1.63)</li>
 	<li>Downloading hyperf/constants (v3.1.63)</li>
 	<li>Downloading hyperf/pool (v3.1.66)</li>
 	<li>Downloading hyperf/event (v3.1.63)</li>
 	<li>Downloading symfony/translation-contracts (v3.6.1)</li>
 	<li>Downloading symfony/translation (v6.4.34)</li>
 	<li>Downloading psr/clock (1.0.0)</li>
 	<li>Downloading carbonphp/carbon-doctrine-types (3.2.0)</li>
 	<li>Downloading nesbot/carbon (2.73.0)</li>
 	<li>Downloading hyperf/database (v3.1.67)</li>
 	<li>Downloading hyperf/model-listener (v3.1.63)</li>
 	<li>Downloading fig/http-message-util (1.1.5)</li>
 	<li>Downloading hyperf/framework (v3.1.63)</li>
 	<li>Downloading hyperf/db-connection (v3.1.66)</li>
 	<li>Downloading hyperf/devtool (v3.1.66)</li>
 	<li>Downloading psr/http-client (1.0.3)</li>
 	<li>Downloading swow/psr7-plus (v1.1.2)</li>
 	<li>Downloading laminas/laminas-stdlib (3.20.0)</li>
 	<li>Downloading hyperf/laminas-mime (v3.0.0)</li>
 	<li>Downloading hyperf/http-message (v3.1.65)</li>
 	<li>Downloading psr/http-server-handler (1.0.2)</li>
 	<li>Downloading psr/http-server-middleware (1.0.2)</li>
 	<li>Downloading hyperf/dispatcher (v3.1.63)</li>
 	<li>Downloading hyperf/exception-handler (v3.1.63)</li>
 	<li>Downloading guzzlehttp/guzzle (7.10.0)</li>
 	<li>Downloading hyperf/guzzle (v3.1.66)</li>
 	<li>Downloading monolog/monolog (3.10.0)</li>
 	<li>Downloading hyperf/logger (v3.1.63)</li>
 	<li>Downloading hyperf/memory (v3.1.63)</li>
 	<li>Downloading hyperf/process (v3.1.63)</li>
 	<li>Downloading hyperf/redis (v3.1.66)</li>
 	<li>Downloading hyperf/serializer (v3.1.63)</li>
 	<li>Downloading hyperf/server (v3.1.63)</li>
 	<li>Downloading symfony/polyfill-php83 (v1.33.0)</li>
 	<li>Downloading symfony/http-foundation (v6.4.35)</li>
 	<li>Downloading sebastian/version (4.0.1)</li>
 	<li>Downloading sebastian/type (4.0.0)</li>
 	<li>Downloading sebastian/recursion-context (5.0.1)</li>
 	<li>Downloading sebastian/object-reflector (3.0.0)</li>
 	<li>Downloading sebastian/object-enumerator (5.0.0)</li>
 	<li>Downloading sebastian/global-state (6.0.2)</li>
 	<li>Downloading sebastian/exporter (5.1.4)</li>
 	<li>Downloading sebastian/environment (6.1.0)</li>
 	<li>Downloading sebastian/comparator (5.0.5)</li>
 	<li>Downloading sebastian/code-unit (2.0.0)</li>
 	<li>Downloading sebastian/cli-parser (2.0.1)</li>
 	<li>Downloading phpunit/php-timer (6.0.0)</li>
 	<li>Downloading phpunit/php-text-template (3.0.1)</li>
 	<li>Downloading phpunit/php-invoker (4.0.0)</li>
 	<li>Downloading phpunit/php-file-iterator (4.1.0)</li>
 	<li>Downloading theseer/tokenizer (1.3.1)</li>
 	<li>Downloading sebastian/lines-of-code (2.0.2)</li>
 	<li>Downloading sebastian/complexity (3.2.0)</li>
 	<li>Downloading sebastian/code-unit-reverse-lookup (3.0.0)</li>
 	<li>Downloading phpunit/php-code-coverage (10.1.16)</li>
 	<li>Downloading phar-io/version (3.2.1)</li>
 	<li>Downloading phar-io/manifest (2.0.4)</li>
 	<li>Downloading myclabs/deep-copy (1.13.4)</li>
 	<li>Downloading phpunit/phpunit (10.5.63)</li>
 	<li>Downloading nikic/fast-route (v1.3.0)</li>
 	<li>Downloading hyperf/http-server (v3.1.65)</li>
 	<li>Downloading hyperf/testing (v3.1.63)</li>
 	<li>Downloading hamcrest/hamcrest-php (v2.1.1)</li>
 	<li>Downloading mockery/mockery (1.6.12)</li>
 	<li>Downloading phpstan/phpstan (1.12.33)</li>
 	<li>Downloading swoole/ide-helper (5.1.8)</li>
 	<li>Installing composer/pcre (3.3.2): Extracting archive</li>
 	<li>Installing doctrine/inflector (2.1.0): Extracting archive</li>
 	<li>Installing doctrine/instantiator (1.5.0): Extracting archive</li>
 	<li>Installing symfony/deprecation-contracts (v3.6.0): Extracting archive</li>
 	<li>Installing psr/container (2.0.2): Extracting archive</li>
 	<li>Installing symfony/service-contracts (v3.6.1): Extracting archive</li>
 	<li>Installing symfony/stopwatch (v6.4.24): Extracting archive</li>
 	<li>Installing symfony/process (v6.4.33): Extracting archive</li>
 	<li>Installing symfony/polyfill-php84 (v1.33.0): Extracting archive</li>
 	<li>Installing symfony/polyfill-php81 (v1.33.0): Extracting archive</li>
 	<li>Installing symfony/polyfill-php80 (v1.33.0): Extracting archive</li>
 	<li>Installing symfony/polyfill-mbstring (v1.33.0): Extracting archive</li>
 	<li>Installing symfony/options-resolver (v6.4.30): Extracting archive</li>
 	<li>Installing symfony/finder (v6.4.34): Extracting archive</li>
 	<li>Installing symfony/polyfill-ctype (v1.33.0): Extracting archive</li>
 	<li>Installing symfony/filesystem (v6.4.34): Extracting archive</li>
 	<li>Installing psr/event-dispatcher (1.0.0): Extracting archive</li>
 	<li>Installing symfony/event-dispatcher-contracts (v3.6.0): Extracting archive</li>
 	<li>Installing symfony/event-dispatcher (v6.4.32): Extracting archive</li>
 	<li>Installing symfony/polyfill-intl-normalizer (v1.33.0): Extracting archive</li>
 	<li>Installing symfony/polyfill-intl-grapheme (v1.33.0): Extracting archive</li>
 	<li>Installing symfony/string (v6.4.34): Extracting archive</li>
 	<li>Installing symfony/console (v6.4.35): Extracting archive</li>
 	<li>Installing sebastian/diff (5.1.1): Extracting archive</li>
 	<li>Installing react/event-loop (v1.6.0): Extracting archive</li>
 	<li>Installing evenement/evenement (v3.0.2): Extracting archive</li>
 	<li>Installing react/stream (v1.4.0): Extracting archive</li>
 	<li>Installing react/promise (v3.3.0): Extracting archive</li>
 	<li>Installing react/cache (v1.2.0): Extracting archive</li>
 	<li>Installing react/dns (v1.14.0): Extracting archive</li>
 	<li>Installing react/socket (v1.17.0): Extracting archive</li>
 	<li>Installing react/child-process (v0.6.7): Extracting archive</li>
 	<li>Installing fidry/cpu-core-counter (1.3.0): Extracting archive</li>
 	<li>Installing psr/log (3.0.2): Extracting archive</li>
 	<li>Installing composer/xdebug-handler (3.0.5): Extracting archive</li>
 	<li>Installing composer/semver (3.4.4): Extracting archive</li>
 	<li>Installing clue/ndjson-react (v1.3.0): Extracting archive</li>
 	<li>Installing friendsofphp/php-cs-fixer (v3.94.2): Extracting archive</li>
 	<li>Installing guzzlehttp/promises (2.3.0): Extracting archive</li>
 	<li>Installing ralouphie/getallheaders (3.0.3): Extracting archive</li>
 	<li>Installing psr/http-message (2.0): Extracting archive</li>
 	<li>Installing psr/http-factory (1.1.0): Extracting archive</li>
 	<li>Installing guzzlehttp/psr7 (2.9.0): Extracting archive</li>
 	<li>Installing hyperf/tappable (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/macroable (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/conditionable (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/stringable (v3.1.65): Extracting archive</li>
 	<li>Installing hyperf/contract (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/collection (v3.1.64): Extracting archive</li>
 	<li>Installing hyperf/engine-contract (v1.14.0): Extracting archive</li>
 	<li>Installing hyperf/engine (v2.15.0): Extracting archive</li>
 	<li>Installing hyperf/context (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/coroutine (v3.1.65): Extracting archive</li>
 	<li>Installing hyperf/support (v3.1.65): Extracting archive</li>
 	<li>Installing phpoption/phpoption (1.9.5): Extracting archive</li>
 	<li>Installing graham-campbell/result-type (v1.1.4): Extracting archive</li>
 	<li>Installing vlucas/phpdotenv (v5.6.3): Extracting archive</li>
 	<li>Installing php-di/phpdoc-reader (2.2.1): Extracting archive</li>
 	<li>Installing nikic/php-parser (v4.19.5): Extracting archive</li>
 	<li>Installing hyperf/stdlib (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/pipeline (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/code-parser (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/di (v3.1.67): Extracting archive</li>
 	<li>Installing hyperf/coordinator (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/command (v3.1.64): Extracting archive</li>
 	<li>Installing hyperf/codec (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/async-queue (v3.1.64): Extracting archive</li>
 	<li>Installing psr/simple-cache (3.0.0): Extracting archive</li>
 	<li>Installing hyperf/cache (v3.1.67): Extracting archive</li>
 	<li>Installing hyperf/config (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/constants (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/pool (v3.1.66): Extracting archive</li>
 	<li>Installing hyperf/event (v3.1.63): Extracting archive</li>
 	<li>Installing symfony/translation-contracts (v3.6.1): Extracting archive</li>
 	<li>Installing symfony/translation (v6.4.34): Extracting archive</li>
 	<li>Installing psr/clock (1.0.0): Extracting archive</li>
 	<li>Installing carbonphp/carbon-doctrine-types (3.2.0): Extracting archive</li>
 	<li>Installing nesbot/carbon (2.73.0): Extracting archive</li>
 	<li>Installing hyperf/database (v3.1.67): Extracting archive</li>
 	<li>Installing hyperf/model-listener (v3.1.63): Extracting archive</li>
 	<li>Installing fig/http-message-util (1.1.5): Extracting archive</li>
 	<li>Installing hyperf/framework (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/db-connection (v3.1.66): Extracting archive</li>
 	<li>Installing hyperf/devtool (v3.1.66): Extracting archive</li>
 	<li>Installing psr/http-client (1.0.3): Extracting archive</li>
 	<li>Installing swow/psr7-plus (v1.1.2): Extracting archive</li>
 	<li>Installing laminas/laminas-stdlib (3.20.0): Extracting archive</li>
 	<li>Installing hyperf/laminas-mime (v3.0.0): Extracting archive</li>
 	<li>Installing hyperf/http-message (v3.1.65): Extracting archive</li>
 	<li>Installing psr/http-server-handler (1.0.2): Extracting archive</li>
 	<li>Installing psr/http-server-middleware (1.0.2): Extracting archive</li>
 	<li>Installing hyperf/dispatcher (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/exception-handler (v3.1.63): Extracting archive</li>
 	<li>Installing guzzlehttp/guzzle (7.10.0): Extracting archive</li>
 	<li>Installing hyperf/guzzle (v3.1.66): Extracting archive</li>
 	<li>Installing monolog/monolog (3.10.0): Extracting archive</li>
 	<li>Installing hyperf/logger (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/memory (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/process (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/redis (v3.1.66): Extracting archive</li>
 	<li>Installing hyperf/serializer (v3.1.63): Extracting archive</li>
 	<li>Installing hyperf/server (v3.1.63): Extracting archive</li>
 	<li>Installing symfony/polyfill-php83 (v1.33.0): Extracting archive</li>
 	<li>Installing symfony/http-foundation (v6.4.35): Extracting archive</li>
 	<li>Installing sebastian/version (4.0.1): Extracting archive</li>
 	<li>Installing sebastian/type (4.0.0): Extracting archive</li>
 	<li>Installing sebastian/recursion-context (5.0.1): Extracting archive</li>
 	<li>Installing sebastian/object-reflector (3.0.0): Extracting archive</li>
 	<li>Installing sebastian/object-enumerator (5.0.0): Extracting archive</li>
 	<li>Installing sebastian/global-state (6.0.2): Extracting archive</li>
 	<li>Installing sebastian/exporter (5.1.4): Extracting archive</li>
 	<li>Installing sebastian/environment (6.1.0): Extracting archive</li>
 	<li>Installing sebastian/comparator (5.0.5): Extracting archive</li>
 	<li>Installing sebastian/code-unit (2.0.0): Extracting archive</li>
 	<li>Installing sebastian/cli-parser (2.0.1): Extracting archive</li>
 	<li>Installing phpunit/php-timer (6.0.0): Extracting archive</li>
 	<li>Installing phpunit/php-text-template (3.0.1): Extracting archive</li>
 	<li>Installing phpunit/php-invoker (4.0.0): Extracting archive</li>
 	<li>Installing phpunit/php-file-iterator (4.1.0): Extracting archive</li>
 	<li>Installing theseer/tokenizer (1.3.1): Extracting archive</li>
 	<li>Installing sebastian/lines-of-code (2.0.2): Extracting archive</li>
 	<li>Installing sebastian/complexity (3.2.0): Extracting archive</li>
 	<li>Installing sebastian/code-unit-reverse-lookup (3.0.0): Extracting archive</li>
 	<li>Installing phpunit/php-code-coverage (10.1.16): Extracting archive</li>
 	<li>Installing phar-io/version (3.2.1): Extracting archive</li>
 	<li>Installing phar-io/manifest (2.0.4): Extracting archive</li>
 	<li>Installing myclabs/deep-copy (1.13.4): Extracting archive</li>
 	<li>Installing phpunit/phpunit (10.5.63): Extracting archive</li>
 	<li>Installing nikic/fast-route (v1.3.0): Extracting archive</li>
 	<li>Installing hyperf/http-server (v3.1.65): Extracting archive</li>
 	<li>Installing hyperf/testing (v3.1.63): Extracting archive</li>
 	<li>Installing hamcrest/hamcrest-php (v2.1.1): Extracting archive</li>
 	<li>Installing mockery/mockery (1.6.12): Extracting archive</li>
 	<li>Installing phpstan/phpstan (1.12.33): Extracting archive</li>
 	<li>Installing swoole/ide-helper (5.1.8): Extracting archive
27 package suggestions were added by new dependencies, use <code>composer suggest</code> to see details.
Generating optimized autoload files</li>
</ul>
<blockquote>rm -rf runtime/container
114 packages you are using are looking for funding.
Use the <code>composer fund</code> command to find out more!
No security vulnerability advisories found.
/data/project #


]]>
https://www.shuijingwanwq.com/2026/03/20/9355/feed/ 0
在 Spatie\QueryBuilder ,报错:Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict() https://www.shuijingwanwq.com/2024/09/14/8810/ https://www.shuijingwanwq.com/2024/09/14/8810/#respond Sat, 14 Sep 2024 02:15:55 +0000 5.7.0]]> https://www.shuijingwanwq.com/?p=8810 浏览量: 106 1、在 Spatie\QueryBuilder ,报错:Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict()。如图1
在 Spatie\QueryBuilder ,报错:Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict()

图1



{
    "status_code": 500,
    "code": 0,
    "message": "Call to undefined method Spatie\\QueryBuilder\\AllowedFilter::endsWithStrict()"
}


2、在 vendor/spatie/laravel-query-builder/src/AllowedFilter.php 中搜索:endsWithStrict,确认 endsWithStrict 方法不存在。 3、查看 composer.json ,”spatie/laravel-query-builder”: “^5.2”, 。使用 Composer 自动更新到该包的最新兼容版本,5.2.0 => 5.7.0。如图2
查看 composer.json ,"spatie/laravel-query-builder": "^5.2", 。使用 Composer 自动更新到该包的最新兼容版本,5.2.0 => 5.7.0

图2



PS E:\wwwroot\object> composer update spatie/laravel-query-builder
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
  - Upgrading spatie/laravel-query-builder (5.2.0 => 5.7.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 1 removal
  - Downloading spatie/laravel-query-builder (5.7.0)
  - Removing laravel/telescope (v5.2.2)
  - Upgrading spatie/laravel-query-builder (5.2.0 => 5.7.0): Extracting archive
Generating optimized autoload files


4、在 Spatie\QueryBuilder ,不再报错。查看生成的 SQL,符合预期。如图3
在 Spatie\QueryBuilder ,不再报错。查看生成的 SQL,符合预期

图3

<pre class="wp-block-syntaxhighlighter-code">

select
  `table`.*
from
  `table`
where
  `table`.`shipping_type` = 2
  and `shipping_at_gmt` >= '2024-06-14 02:00:51'
  and `shipping_at_gmt` <= '2024-09-14 02:00:51'
  and (
    `table`.`plat_order_no` LIKE '%GM'
    or `table`.`plat_order_no` LIKE '%20'
  )
order by
  `operated_at_gmt` desc
limit
  100 offset 0

</pre>
]]>
https://www.shuijingwanwq.com/2024/09/14/8810/feed/ 0
执行:composer install 时,提示:enqueue/rdkafka 0.10.19 requires ext-rdkafka -> it is missing from your system. Install or enable PHP’s rdkafka extension. https://www.shuijingwanwq.com/2023/12/13/8274/ https://www.shuijingwanwq.com/2023/12/13/8274/#respond Wed, 13 Dec 2023 01:48:18 +0000 https://www.shuijingwanwq.com/?p=8274 浏览量: 87

1、执行:composer install 时,提示:enqueue/rdkafka 0.10.19 requires ext-rdkafka -> it is missing from your system. Install or enable PHP’s rdkafka extension.。如图1

执行:composer install 时,提示:enqueue/rdkafka 0.10.19 requires ext-rdkafka -> it is missing from your system. Install or enable PHP's rdkafka extension.

图1


PS E:\wwwroot\object> composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - enqueue/rdkafka is locked to version 0.10.19 and an update of this package was not requested.
    - enqueue/rdkafka 0.10.19 requires ext-rdkafka ^4.0|^5.0|^6.0 -> it is missing from your system. Install or enable PHP's rdkafka extension.

To enable extensions, verify that they are enabled in your .ini files:
    - C:\php-7.4.27\php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-rdkafka` to temporarily ignore these required extensions.


2、决定启用 PHP 的 rdkafka 扩展。打开:https://pecl.php.net/package/rdkafka/6.0.1/windows ,下载 7.4 Thread Safe (TS) x64。解压缩 php_rdkafka-6.0.1-7.4-ts-vc15-x64 后,将 php_rdkafka.dll 复制至:C:\php-7.4.27\ext\php_rdkafka.dll。然后编辑 php.ini,添加 extension=rdkafka

3、重新启动 PHP 时,报错:PHP Warning: PHP Startup: Unable to load dynamic library ‘rdkafka’。如图2

重新启动 PHP 时,报错:PHP Warning: PHP Startup: Unable to load dynamic library 'rdkafka'

图2

PS C:\Users\Lenovo> php-cgi.exe -b 127.0.0.1:9000-c C:/php-7.4.27/php.ini
PHP Warning:  PHP Startup: Unable to load dynamic library 'rdkafka' (tried: C:/php-7.4.27/ext\rdkafka (鎵句笉鍒版寚瀹氱殑妯″潡銆?, C:/php-7.4.27/ext\php_rdkafka.dll (鎵句 笉鍒版寚瀹氱殑妯″潡銆?) in Unknown on line 0
&lt;br />
&lt;b>Warning&lt;/b>:  PHP Startup: Unable to load dynamic library 'rdkafka' (tried: C:/php-7.4.27/ext\rdkafka (鎵句笉鍒版寚瀹氱殑妯″潡銆?, C:/php-7.4.27/ext\php_rdkafka.dll (鎵句笉鍒版寚瀹氱殑妯″潡銆?) in &lt;b>Unknown&lt;/b> on line &lt;b>0&lt;/b>&lt;br />
 

4、参考:https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/rdkafka.installation.windows.html Installing the rdkafka extension on Windows。将 librdkafka.dll 放入 PHP 根目录(与 php.exe 同一级别),将 php_rdkfaka.dll 文件放入 PHP 扩展目录(默认为“ext”)。将 librdkafka.dll 复制至:C:\php-7.4.27\librdkafka.dll。重新启动 PHP 时,不再报错。

5、查看 phpinfo,搜索:rdkafka,PHP 的 rdkafka 扩展已经启用成功。如图3

查看 phpinfo,搜索:rdkafka,PHP 的 rdkafka 扩展已经启用成功

图3

6、执行:composer install 时,不再提示,运行正常。如图4

执行:composer install 时,不再提示,运行正常

图4

]]>
https://www.shuijingwanwq.com/2023/12/13/8274/feed/ 0
部署 Shopify PHP 应用至生产环境(阿里云、ECS 中的 CentOS 7.7 64位、MySQL 5.7) https://www.shuijingwanwq.com/2023/07/13/7855/ https://www.shuijingwanwq.com/2023/07/13/7855/#comments Thu, 13 Jul 2023 03:06:29 +0000 https://www.shuijingwanwq.com/?p=7855 浏览量: 326

1、现有一个 Shopify PHP 应用,已经可在开发环境中预览。如图1

现有一个 Shopify PHP 应用,已经可在开发环境中预览

图1

2、现准备将其部署至生产环境。如果需要部署应用至生产环境,Shopify 建议创建一个单独的应用。此应用与开发、测试环境共用代码库,但是在 Shopify 合作伙伴中心有自己的记录和配置。以避免在开发和测试过程中影响到生产环境的应用。使用 Shopify 合作伙伴
从头开始创建应用:learn-php-app-0605-prod。如图2

使用 Shopify 合作伙伴从头开始创建应用:learn-php-app-0605-prod

图2

3、检索环境变量,以便可以在稍后的步骤中设置它们。记下 SCOPES、SHOPIFY_API_KEY 和 SHOPIFY_API_SECRET 值。 您需要将这些值设置为托管应用程序的环境变量。


wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605$ npm run shopify app env show

> learn-php-app-ubuntu-2004-0605@1.0.0 shopify
> shopify app env show

?  Which existing app is this for?
&#x2714;  learn-php-app-0605-prod


    SHOPIFY_API_KEY=c7f826670575f7ae069f7e56350465ef
    SHOPIFY_API_SECRET=4de64aa8281e97055cf7698bbe56039e
    SCOPES=write_products



4、参考:基于阿里云的 ECS、RDS,将个人博客迁移升级至:Docker(基于预算考虑,最终未实现)、LNMP(CentOS 7.7、Nginx 1.16、MySQL 5.7、PHP 7.4)、HTTPS 的过程  ,之前的环境是基于 OneinStack 的自动安装。PHP 版本 7.4 已经不再符合 Shopify 应用的运行条件。需要升级至 8.1 版本,尽量与本地环境保持一致。


[root@iZ23wv7v5ggZ ~]# php -v
PHP 7.4.0 (cli) (built: Dec  5 2019 11:56:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.0, Copyright (c), by Zend Technologies




wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605$ php -v
PHP 8.1.18 (cli) (built: Apr 14 2023 04:39:24) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.18, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.18, Copyright (c), by Zend Technologies


5、参考:在 阿里云中的 CentOS 7.7 中卸载 PHP 7.4,然后安装 PHP 8

6、查看阿里云中的 ECS 的 Alibaba Cloud Linux 3 的 PHP 版本


[root@iZ23wv7v5ggZ ~]# php -v
PHP 8.1.19 (cli) (built: Jun  7 2023 11:34:24) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.19, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.19, Copyright (c), by Zend Technologies
[root@iZ23wv7v5ggZ ~]#



7、添加虚拟主机时,设置 SSL 证书失败:Let’s Encrypt Verify error! DNS problem,需要先设置域名的解析。


[root@iZ23wv7v5ggZ www.shuijingwanwq.com]# ~/oneinstack/vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
        1. Use HTTP Only
        2. Use your own SSL Certificate and Key
        3. Use Let's Encrypt to Create SSL Certificate and Key
        q. Exit
Please input the correct option: 3

Please input domain(example: www.example.com): learn-php-app-0605-prod.shuijingwanwq.com
domain=learn-php-app-0605-prod.shuijingwanwq.com

Please input the directory for the domain:learn-php-app-0605-prod.shuijingwanwq.com :
(Default directory: /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com):
Virtual Host Directory=/data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com

Create Virtul Host directory......
set permissions of Virtual Host directory......

Do you want to add more domain name? [y/n]: n

Do you want to redirect all HTTP requests to HTTPS? [y/n]: y

Please select domain cert key length.
Enter one of 2048, 3072, 4096, 8192 will issue a RSA cert.
Enter one of ec-256, ec-384, ec-521 will issue a ECC cert.

Please enter your cert key length (default 2048):

Let's Encrypt Verify error! DNS problem: NXDOMAIN looking up A for learn-php-app-0605-prod.shuijingwanwq.com
[Wed Jun  7 04:44:59 PM CST 2023] Using CA: https://acme.zerossl.com/v2/DV90
[Wed Jun  7 04:44:59 PM CST 2023] Creating domain key
[Wed Jun  7 04:44:59 PM CST 2023] The domain key is here: /root/.acme.sh/learn-php-app-0605-prod.shuijingwanwq.com/learn-php-app-0605-prod.shuijingwanwq.com.key
[Wed Jun  7 04:44:59 PM CST 2023] Single domain='learn-php-app-0605-prod.shuijingwanwq.com'
[Wed Jun  7 04:44:59 PM CST 2023] Getting domain auth token for each domain
[Wed Jun  7 04:45:05 PM CST 2023] Getting webroot for domain='learn-php-app-0605-prod.shuijingwanwq.com'
[Wed Jun  7 04:45:05 PM CST 2023] Verifying: learn-php-app-0605-prod.shuijingwanwq.com
[Wed Jun  7 04:45:07 PM CST 2023] Processing, The CA is processing your order, please just wait. (1/30)
[Wed Jun  7 04:45:11 PM CST 2023] learn-php-app-0605-prod.shuijingwanwq.com:Verify error:"error":{
[Wed Jun  7 04:45:11 PM CST 2023] Please add '--debug' or '--log' to check more details.
[Wed Jun  7 04:45:11 PM CST 2023] See: https://github.com/acmesh-official/acme.sh/wiki/How-to-debug-acme.sh
Error: Create Let's Encrypt SSL Certificate failed!
[root@iZ23wv7v5ggZ www.shuijingwanwq.com]#



8、在阿里云 云解析DNS 中添加记录。如图3

在阿里云 云解析DNS 中添加记录

图3

9、再次添加虚拟主机


[root@iZ23wv7v5ggZ www.shuijingwanwq.com]# ~/oneinstack/vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
        1. Use HTTP Only
        2. Use your own SSL Certificate and Key
        3. Use Let's Encrypt to Create SSL Certificate and Key
        q. Exit
Please input the correct option: 3

Please input domain(example: www.example.com): learn-php-app-0605-prod.shuijingwanwq.com
domain=learn-php-app-0605-prod.shuijingwanwq.com

Please input the directory for the domain:learn-php-app-0605-prod.shuijingwanwq.com :
(Default directory: /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com):
Virtual Host Directory=/data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com

Create Virtul Host directory......
set permissions of Virtual Host directory......

Do you want to add more domain name? [y/n]: n

Do you want to redirect all HTTP requests to HTTPS? [y/n]: y

Please select domain cert key length.
Enter one of 2048, 3072, 4096, 8192 will issue a RSA cert.
Enter one of ec-256, ec-384, ec-521 will issue a ECC cert.

Please enter your cert key length (default 2048):
[Wed Jun  7 04:51:49 PM CST 2023] Using CA: https://acme.zerossl.com/v2/DV90
[Wed Jun  7 04:51:49 PM CST 2023] Single domain='learn-php-app-0605-prod.shuijingwanwq.com'
[Wed Jun  7 04:51:49 PM CST 2023] Getting domain auth token for each domain
[Wed Jun  7 04:51:54 PM CST 2023] Getting webroot for domain='learn-php-app-0605-prod.shuijingwanwq.com'
[Wed Jun  7 04:51:54 PM CST 2023] Verifying: learn-php-app-0605-prod.shuijingwanwq.com
[Wed Jun  7 04:51:55 PM CST 2023] Processing, The CA is processing your order, please just wait. (1/30)
[Wed Jun  7 04:52:01 PM CST 2023] Success
[Wed Jun  7 04:52:01 PM CST 2023] Verify finished, start to sign.
[Wed Jun  7 04:52:01 PM CST 2023] Lets finalize the order.
[Wed Jun  7 04:52:01 PM CST 2023] Le_OrderFinalize='https://acme.zerossl.com/v2/DV90/order/CLf6pxWJkdxtQylgNxS_Jg/finalize'
[Wed Jun  7 04:52:02 PM CST 2023] Order status is processing, lets sleep and retry.
[Wed Jun  7 04:52:02 PM CST 2023] Retry after: 15
[Wed Jun  7 04:52:18 PM CST 2023] Polling order status: https://acme.zerossl.com/v2/DV90/order/CLf6pxWJkdxtQylgNxS_Jg
[Wed Jun  7 04:52:20 PM CST 2023] Downloading cert.
[Wed Jun  7 04:52:20 PM CST 2023] Le_LinkCert='https://acme.zerossl.com/v2/DV90/cert/B2uRnJRfyVAP2B9aqQ2_Lw'
[Wed Jun  7 04:52:22 PM CST 2023] Cert success.
-----BEGIN CERTIFICATE-----
*******************
-----END CERTIFICATE-----
[Wed Jun  7 04:52:22 PM CST 2023] Your cert is in: /root/.acme.sh/learn-php-app-0605-prod.shuijingwanwq.com/learn-php-app-0605-prod.shuijingwanwq.com.cer
[Wed Jun  7 04:52:22 PM CST 2023] Your cert key is in: /root/.acme.sh/learn-php-app-0605-prod.shuijingwanwq.com/learn-php-app-0605-prod.shuijingwanwq.com.key
[Wed Jun  7 04:52:22 PM CST 2023] The intermediate CA cert is in: /root/.acme.sh/learn-php-app-0605-prod.shuijingwanwq.com/ca.cer
[Wed Jun  7 04:52:22 PM CST 2023] And the full chain certs is there: /root/.acme.sh/learn-php-app-0605-prod.shuijingwanwq.com/fullchain.cer

Do you want to add hotlink protection? [y/n]: y

Allow Rewrite rule? [y/n]: y

Please input the rewrite of programme :
wordpress,opencart,magento2,drupal,joomla,codeigniter,laravel
thinkphp,pathinfo,discuz,typecho,ecshop,nextcloud,zblog,whmcs rewrite was exist.
(Default rewrite: other): laravel
You choose rewrite=laravel

Allow Nginx/Tengine/OpenResty access_log? [y/n]: y
You access log file=/data/wwwlogs/learn-php-app-0605-prod.shuijingwanwq.com_nginx.log

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reload Nginx......

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################
Your domain:                  learn-php-app-0605-prod.shuijingwanwq.com
Virtualhost conf:             /usr/local/nginx/conf/vhost/learn-php-app-0605-prod.shuijingwanwq.com.conf
Directory of:                 /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com
Rewrite rule:                 /usr/local/nginx/conf/rewrite/laravel.conf
Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/learn-php-app-0605-prod.shuijingwanwq.com.crt
SSL Private Key:              /usr/local/nginx/conf/ssl/learn-php-app-0605-prod.shuijingwanwq.com.key
[root@iZ23wv7v5ggZ www.shuijingwanwq.com]#



10、添加FTP账号


[root@iZ23wv7v5ggZ www.shuijingwanwq.com]# ~/oneinstack/pureftpd_vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+      #
#                 FTP virtual user account management                 #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
        1. UserAdd
        2. UserMod
        3. UserPasswd
        4. UserDel
        5. ListAllUser
        6. ShowUser
        q. Exit
Please input the correct option: 1

Please input a username: learn-php-app-0605-prod.shuijingwanwq.com

Please input the password: XZzqpC4k3Clf6Oup26e

Please input the directory(Default directory: /data/wwwroot): /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com
Password:
Enter it again:
#####################################

[learn-php-app-0605-prod.shuijingwanwq.com] create successful!

You user name is : learn-php-app-0605-prod.shuijingwanwq.com
You Password is : ************
You directory is : /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com



11、此时,需要在本地环境中构建生产环境中的应用,避免在生产环境中构建,因为生产环境中暂不支持构建所需要的前提条件,比如说 npm、composer 等。SHOPIFY_API_KEY 需要使用 步骤 3 中检索出的变量值。复制应用目录 learn-php-app-ubuntu-2004-0605/web 为 learn-php-app-0605-prod。目录 learn-php-app-0605-prod 仅需要构建后,上传至生产环境,因此,开发环境的依赖文件皆不需要。


wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app$ cd learn-php-app-0605-prod/
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod$ ls -l
total 300
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:38 app
-rwxrwxrwx 1 wangqiang wangqiang   1690 Jun  5 15:02 artisan
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:38 bootstrap
-rwxrwxrwx 1 wangqiang wangqiang   2238 Jun  5 15:02 composer.json
-rwxrwxrwx 1 wangqiang wangqiang 304694 Jun  6 09:35 composer.lock
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:38 config
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:38 database
-rwxrwxrwx 1 wangqiang wangqiang    450 Jun  5 15:02 entrypoint.sh
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:39 frontend
-rwxrwxrwx 1 wangqiang wangqiang    860 Jun  5 15:00 nginx.conf
-rwxrwxrwx 1 wangqiang wangqiang   1202 Jun  5 15:00 phpunit.xml
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:39 public
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:39 resources
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:39 routes
-rwxrwxrwx 1 wangqiang wangqiang    563 Jun  5 15:00 server.php
-rwxrwxrwx 1 wangqiang wangqiang     75 Jun  5 15:00 shopify.web.toml
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:39 storage
drwxrwxrwx 1 wangqiang wangqiang   4096 Jun  7 17:42 vendor



12、编辑 .env ,设置为生产环境中的配置值


APP_NAME="Shopify PHP App 0605 Prod"
APP_ENV=production
APP_KEY=***********
APP_DEBUG=false

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=************
DB_PORT=3306
DB_DATABASE=learn_php_app_0605_prod
DB_USERNAME=learn_php_app_0605_prod
DB_PASSWORD=**********



13、构建前端与后端,报错:/bin/sh: 1: vite: not found,需要先执行:npm install 。如图4

构建前端与后端,报错:/bin/sh: 1: vite: not found,需要先执行:npm install

图4


wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod/frontend$ SHOPIFY_API_KEY=c7f826670575f7ae069f7e56350465ef yarn build
yarn run v1.22.15
$ vite build
/bin/sh: 1: vite: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod/frontend$ npm install
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.

added 354 packages, and audited 360 packages in 3m

41 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod/frontend$ SHOPIFY_API_KEY=c7f826670575f7ae069f7e56350465ef npm run build

> shopify-frontend-template-react@1.0.0 build
> vite build

vite v4.3.9 building for production...
✓ 1966 modules transformed.
dist/assets/empty-state-8039a1e1.svg      0.26 kB │ gzip:   0.20 kB
dist/index.html                           0.48 kB │ gzip:   0.33 kB
dist/assets/home-trophy-d70b3542.png     20.65 kB
dist/assets/index-37530742.css          371.48 kB │ gzip:  45.42 kB
dist/assets/ko-ef9a93f5.js                0.21 kB │ gzip:   0.15 kB
dist/assets/ja-abb1af27.js                0.21 kB │ gzip:   0.15 kB
dist/assets/zh-4775ba45.js                0.21 kB │ gzip:   0.15 kB
dist/assets/th-32f01d1c.js                0.21 kB │ gzip:   0.15 kB
dist/assets/vi-72f55a87.js                0.23 kB │ gzip:   0.17 kB
dist/assets/nb-79727cd5.js                0.24 kB │ gzip:   0.17 kB
dist/assets/tr-d5c962f0.js                0.24 kB │ gzip:   0.17 kB
dist/assets/nl-ed6c02b1.js                0.28 kB │ gzip:   0.20 kB
dist/assets/de-5d4a5256.js                0.28 kB │ gzip:   0.20 kB
dist/assets/fi-e67a7779.js                0.28 kB │ gzip:   0.20 kB
dist/assets/da-9b835bb8.js                0.31 kB │ gzip:   0.22 kB
dist/assets/cs-d855408e.js                0.32 kB │ gzip:   0.23 kB
dist/assets/sv-8ac62b51.js                0.37 kB │ gzip:   0.25 kB
dist/assets/en-d265ad8d.js                0.41 kB │ gzip:   0.26 kB
dist/assets/es-fd2f35f4.js                0.41 kB │ gzip:   0.29 kB
dist/assets/pt-227fd344.js                0.41 kB │ gzip:   0.29 kB
dist/assets/pt-PT-a0c51464.js             0.41 kB │ gzip:   0.29 kB
dist/assets/pl-ab15c7ea.js                0.42 kB │ gzip:   0.29 kB
dist/assets/fr-23e50d95.js                0.43 kB │ gzip:   0.29 kB
dist/assets/it-08f76780.js                0.45 kB │ gzip:   0.30 kB
dist/assets/en-df34a502.js                1.53 kB │ gzip:   0.77 kB
dist/assets/de-2ae5c9fa.js                1.72 kB │ gzip:   0.90 kB
dist/assets/fr-5253333d.js                1.83 kB │ gzip:   0.94 kB
dist/assets/polyfill-force-11887b4b.js    5.21 kB │ gzip:   2.03 kB
dist/assets/zh-CN-cf74d136.js             7.72 kB │ gzip:   3.26 kB
dist/assets/zh-TW-6a74a185.js             7.86 kB │ gzip:   3.36 kB
dist/assets/ko-2cf626e6.js                8.18 kB │ gzip:   3.39 kB
dist/assets/ja-6f78282b.js                8.35 kB │ gzip:   3.58 kB
dist/assets/en-c240dff3.js                9.95 kB │ gzip:   2.95 kB
dist/assets/vi-e4ef4fd6.js                9.97 kB │ gzip:   3.34 kB
dist/assets/th-2a34d5e0.js               10.14 kB │ gzip:   3.77 kB
dist/assets/sv-a901b08f.js               10.22 kB │ gzip:   3.27 kB
dist/assets/da-1564850b.js               10.30 kB │ gzip:   3.26 kB
dist/assets/nb-0a6d8490.js               10.35 kB │ gzip:   3.25 kB
dist/assets/pl-a603e9c2.js               10.39 kB │ gzip:   3.39 kB
dist/assets/cs-3c753a97.js               10.40 kB │ gzip:   3.50 kB
dist/assets/fi-c0a9d95f.js               10.63 kB │ gzip:   3.41 kB
dist/assets/tr-bd45be97.js               10.68 kB │ gzip:   3.39 kB
dist/assets/it-8bb02787.js               10.72 kB │ gzip:   3.32 kB
dist/assets/pt-PT-af188c06.js            10.85 kB │ gzip:   3.34 kB
dist/assets/nl-0772ea77.js               10.89 kB │ gzip:   3.25 kB
dist/assets/pt-BR-8a1d5660.js            10.94 kB │ gzip:   3.36 kB
dist/assets/es-5e0e20e7.js               10.95 kB │ gzip:   3.39 kB
dist/assets/de-a04fe3bd.js               11.11 kB │ gzip:   3.35 kB
dist/assets/fr-1848494a.js               11.31 kB │ gzip:   3.48 kB
dist/assets/index-41437cc7.js            53.59 kB │ gzip:  18.93 kB
dist/assets/polyfill-904c231f.js        133.64 kB │ gzip:  40.74 kB
dist/assets/index-991532e3.js           618.82 kB │ gzip: 164.28 kB

(!) Some chunks are larger than 500 kBs after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✓ built in 47.73s
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod$ composer build
> composer build-frontend-links
> ln -sf ../frontend/dist/assets public/assets &amp;&amp; ln -sf ../frontend/dist/index.html public/index.html
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod$ cd public/
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-0605-prod/public$ ls -l
total 0
lrwxrwxrwx 1 wangqiang wangqiang   23 Jun  6 10:06 assets -> ../frontend/dist/assets
-rwxrwxrwx 1 wangqiang wangqiang    0 Jun  5 15:00 favicon.ico
lrwxrwxrwx 1 wangqiang wangqiang   27 Jun  8 09:45 index.html -> ../frontend/dist/index.html
-rwxrwxrwx 1 wangqiang wangqiang 1743 Jun  5 15:00 index.php
-rwxrwxrwx 1 wangqiang wangqiang   24 Jun  5 15:00 robots.txt


14、基于 FTP 上传 目录 learn-php-app-0605-prod 下的所有文件。总计大小为 150 MB 左右。上传时间过长,最张决定在生产环境中构建。目录:vendor、frontend/node_modules 不上传。如图5

基于 FTP 上传 目录 learn-php-app-0605-prod 下的所有文件。总计大小为 150 MB 左右。上传时间过长,最张决定在生产环境中构建。目录:vendor、frontend/node_modules 不上传

图5

15、安装 Node.js 与 Composer,Node.js 安装后需要重启实例


[root@iZ23wv7v5ggZ ~]# ~/oneinstack/install.sh --node

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################

Download Nodejs...
--2023-06-08 10:45:47--  https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/v18.14.2/node-v18.14.2-linux-x64.tar.gz
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.15.130, 2402:f000:1:400::2
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.15.130|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 44201520 (42M) [application/octet-stream]
Saving to: ‘node-v18.14.2-linux-x64.tar.gz’

     0K .......... .......... .......... .......... ..........  0%  878K 49s
    50K .......... .......... .......... .......... ..........  0% 1.79M 36s
 43150K .......... .....                                      100% 14.2M=2.7s

2023-06-08 10:45:50 (15.7 MB/s) - ‘node-v18.14.2-linux-x64.tar.gz’ saved [44201520/44201520]

Nodejs installed successfully!
[xprober.php] found
####################Congratulations########################
Total OneinStack Install Time: 0 minutes

[root@iZ23wv7v5ggZ ~]# node -v
-bash: node: command not found

[root@iZ23wv7v5ggZ ~]# ~/oneinstack/addons.sh

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+      #
#                    Install/Uninstall Extensions                     #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
        1. Install/Uninstall PHP Composer
        2. Install/Uninstall fail2ban
        3. Install/Uninstall ngx_lua_waf
        4. Install/Uninstall Python3.6
        q. Exit
Please input the correct option: 1

Please select an action:
        1. install
        2. uninstall
Please input a number:(Default 1 press Enter) 1

PHP Composer installed successfully!

What Are You Doing?
        1. Install/Uninstall PHP Composer
        2. Install/Uninstall fail2ban
        3. Install/Uninstall ngx_lua_waf
        4. Install/Uninstall Python3.6
        q. Exit
Please input the correct option: q
[root@iZ23wv7v5ggZ ~]# composer -V
Composer version 2.5.7 2023-05-24 15:00:39
[root@iZ23wv7v5ggZ ~]# node -v
v18.14.2



16、当FTP上传完毕后,创建数据库(连接信息与 .env 中的保持一致),生成APP_KEY ,执行数据库迁移,构建前端与后端



[root@iZ23wv7v5ggZ frontend]# npm install
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.

added 359 packages, and audited 360 packages in 17s

41 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice
npm notice New minor version of npm available! 9.5.0 -> 9.7.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.7.1
npm notice Run npm install -g npm@9.7.1 to update!
npm notice
[root@iZ23wv7v5ggZ frontend]# SHOPIFY_API_KEY=c7f826670575f7ae069f7e56350465ef npm run build

> shopify-frontend-template-react@1.0.0 build
> vite build

vite v4.3.9 building for production...
✓ 1966 modules transformed.
dist/assets/empty-state-8039a1e1.svg      0.26 kB │ gzip:   0.20 kB
dist/index.html                           0.48 kB │ gzip:   0.33 kB
dist/assets/home-trophy-d70b3542.png     20.65 kB
dist/assets/index-37530742.css          371.48 kB │ gzip:  45.42 kB
dist/assets/ja-abb1af27.js                0.21 kB │ gzip:   0.15 kB
dist/assets/ko-ef9a93f5.js                0.21 kB │ gzip:   0.15 kB
dist/assets/th-32f01d1c.js                0.21 kB │ gzip:   0.15 kB
dist/assets/zh-4775ba45.js                0.21 kB │ gzip:   0.15 kB
dist/assets/vi-72f55a87.js                0.23 kB │ gzip:   0.17 kB
dist/assets/nb-79727cd5.js                0.24 kB │ gzip:   0.17 kB
dist/assets/tr-d5c962f0.js                0.24 kB │ gzip:   0.17 kB
dist/assets/de-5d4a5256.js                0.28 kB │ gzip:   0.20 kB
dist/assets/fi-e67a7779.js                0.28 kB │ gzip:   0.20 kB
dist/assets/nl-ed6c02b1.js                0.28 kB │ gzip:   0.20 kB
dist/assets/da-9b835bb8.js                0.31 kB │ gzip:   0.22 kB
dist/assets/cs-d855408e.js                0.32 kB │ gzip:   0.23 kB
dist/assets/sv-8ac62b51.js                0.37 kB │ gzip:   0.25 kB
dist/assets/en-d265ad8d.js                0.41 kB │ gzip:   0.26 kB
dist/assets/es-fd2f35f4.js                0.41 kB │ gzip:   0.29 kB
dist/assets/pt-227fd344.js                0.41 kB │ gzip:   0.29 kB
dist/assets/pt-PT-a0c51464.js             0.41 kB │ gzip:   0.29 kB
dist/assets/pl-ab15c7ea.js                0.42 kB │ gzip:   0.29 kB
dist/assets/fr-23e50d95.js                0.43 kB │ gzip:   0.29 kB
dist/assets/it-08f76780.js                0.45 kB │ gzip:   0.30 kB
dist/assets/en-df34a502.js                1.53 kB │ gzip:   0.77 kB
dist/assets/de-2ae5c9fa.js                1.72 kB │ gzip:   0.90 kB
dist/assets/fr-5253333d.js                1.83 kB │ gzip:   0.94 kB
dist/assets/polyfill-force-11887b4b.js    5.21 kB │ gzip:   2.03 kB
dist/assets/zh-CN-cf74d136.js             7.72 kB │ gzip:   3.26 kB
dist/assets/zh-TW-6a74a185.js             7.86 kB │ gzip:   3.36 kB
dist/assets/ko-2cf626e6.js                8.18 kB │ gzip:   3.39 kB
dist/assets/ja-6f78282b.js                8.35 kB │ gzip:   3.58 kB
dist/assets/en-c240dff3.js                9.95 kB │ gzip:   2.95 kB
dist/assets/vi-e4ef4fd6.js                9.97 kB │ gzip:   3.34 kB
dist/assets/th-2a34d5e0.js               10.14 kB │ gzip:   3.77 kB
dist/assets/sv-a901b08f.js               10.22 kB │ gzip:   3.27 kB
dist/assets/da-1564850b.js               10.30 kB │ gzip:   3.26 kB
dist/assets/nb-0a6d8490.js               10.35 kB │ gzip:   3.25 kB
dist/assets/pl-a603e9c2.js               10.39 kB │ gzip:   3.39 kB
dist/assets/cs-3c753a97.js               10.40 kB │ gzip:   3.50 kB
dist/assets/fi-c0a9d95f.js               10.63 kB │ gzip:   3.41 kB
dist/assets/tr-bd45be97.js               10.68 kB │ gzip:   3.39 kB
dist/assets/it-8bb02787.js               10.72 kB │ gzip:   3.32 kB
dist/assets/pt-PT-af188c06.js            10.85 kB │ gzip:   3.34 kB
dist/assets/nl-0772ea77.js               10.89 kB │ gzip:   3.25 kB
dist/assets/pt-BR-8a1d5660.js            10.94 kB │ gzip:   3.36 kB
dist/assets/es-5e0e20e7.js               10.95 kB │ gzip:   3.39 kB
dist/assets/de-a04fe3bd.js               11.11 kB │ gzip:   3.35 kB
dist/assets/fr-1848494a.js               11.31 kB │ gzip:   3.48 kB
dist/assets/index-41437cc7.js            53.59 kB │ gzip:  18.93 kB
dist/assets/polyfill-904c231f.js        133.64 kB │ gzip:  40.74 kB
dist/assets/index-991532e3.js           618.82 kB │ gzip: 164.28 kB

(!) Some chunks are larger than 500 kBs after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✓ built in 21.56s
[root@iZ23wv7v5ggZ frontend]# cd ..
[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - league/flysystem is locked to version 1.1.10 and an update of this package was not requested.
    - league/flysystem 1.1.10 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
  Problem 2
    - league/mime-type-detection is locked to version 1.11.0 and an update of this package was not requested.
    - league/mime-type-detection 1.11.0 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
  Problem 3
    - league/flysystem 1.1.10 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
    - laravel/framework v8.83.27 requires league/flysystem ^1.1 -> satisfiable by league/flysystem[1.1.10].
    - laravel/framework is locked to version v8.83.27 and an update of this package was not requested.

To enable extensions, verify that they are enabled in your .ini files:
    - /usr/local/php/etc/php.ini
    - /usr/local/php/etc/php.d/02-opcache.ini
    - /usr/local/php/etc/php.d/03-imagick.ini
    - /usr/local/php/etc/php.d/04-ldap.ini
    - /usr/local/php/etc/php.d/05-redis.ini
    - /usr/local/php/etc/php.d/07-mongodb.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-fileinfo` to temporarily ignore these required extensions.



17、安装 PHP 扩展 fileinfo 后,再次执行。报错:The Process class relies on proc_open, which is not available on your PHP installation.

[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 114 installs, 0 updates, 0 removals
proc_open is disabled so 'unzip' and '7z' commands cannot be used, zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Enabling proc_open and installing 'unzip' or '7z' (21.01+) may remediate them.
  - Downloading brick/math (0.11.0)
  - Downloading psr/log (2.0.0)
  - Downloading psr/cache (3.0.0)
  - Downloading doctrine/event-manager (2.0.0)
  - Downloading doctrine/deprecations (v1.1.1)
  - Downloading doctrine/cache (2.2.0)
  - Downloading doctrine/dbal (3.6.3)
  - Downloading doctrine/lexer (1.2.3)
  - Downloading symfony/polyfill-ctype (v1.27.0)
  - Downloading webmozart/assert (1.11.0)
  - Downloading dragonmantank/cron-expression (v3.3.2)
  - Downloading symfony/polyfill-php80 (v1.27.0)
  - Downloading symfony/polyfill-mbstring (v1.27.0)
  - Downloading symfony/var-dumper (v5.4.24)
  - Downloading symfony/polyfill-intl-normalizer (v1.27.0)
  - Downloading symfony/polyfill-intl-grapheme (v1.27.0)
  - Downloading symfony/string (v6.3.0)
  - Downloading symfony/deprecation-contracts (v3.3.0)
  - Downloading psr/container (1.1.2)
  - Downloading symfony/service-contracts (v2.5.2)
  - Downloading symfony/polyfill-php73 (v1.27.0)
  - Downloading symfony/console (v5.4.24)
  - Downloading monolog/monolog (2.9.1)
  - Downloading voku/portable-ascii (1.6.1)
  - Downloading phpoption/phpoption (1.9.1)
  - Downloading graham-campbell/result-type (v1.1.1)
  - Downloading vlucas/phpdotenv (v5.5.0)
  - Downloading symfony/css-selector (v6.3.0)
  - Downloading tijsverkoyen/css-to-inline-styles (2.2.6)
  - Downloading symfony/routing (v5.4.22)
  - Downloading symfony/process (v5.4.24)
  - Downloading symfony/polyfill-php72 (v1.27.0)
  - Downloading symfony/polyfill-intl-idn (v1.27.0)
  - Downloading symfony/mime (v5.4.23)
  - Downloading symfony/http-foundation (v5.4.24)
  - Downloading psr/event-dispatcher (1.0.0)
  - Downloading symfony/event-dispatcher-contracts (v3.3.0)
  - Downloading symfony/event-dispatcher (v6.3.0)
  - Downloading symfony/error-handler (v5.4.24)
  - Downloading symfony/http-kernel (v5.4.24)
  - Downloading symfony/finder (v5.4.21)
  - Downloading symfony/polyfill-iconv (v1.27.0)
  - Downloading egulias/email-validator (2.1.25)
  - Downloading swiftmailer/swiftmailer (v6.3.0)
  - Downloading ramsey/collection (2.0.0)
  - Downloading ramsey/uuid (4.7.4)
  - Downloading psr/simple-cache (1.0.1)
  - Downloading opis/closure (3.6.3)
  - Downloading symfony/translation-contracts (v3.3.0)
  - Downloading symfony/translation (v6.3.0)
  - Downloading nesbot/carbon (2.67.0)
  - Downloading league/mime-type-detection (1.11.0)
  - Downloading league/flysystem (1.1.10)
  - Downloading nette/utils (v4.0.0)
  - Downloading nette/schema (v1.2.3)
  - Downloading dflydev/dot-access-data (v3.0.2)
  - Downloading league/config (v1.2.0)
  - Downloading league/commonmark (2.4.0)
  - Downloading laravel/serializable-closure (v1.3.0)
  - Downloading doctrine/inflector (2.0.6)
  - Downloading laravel/framework (v8.83.27)
  - Downloading facade/ignition-contracts (1.0.2)
  - Downloading facade/flare-client-php (1.10.0)
  - Downloading facade/ignition (2.17.7)
  - Downloading fakerphp/faker (v1.22.0)
  - Downloading fideloper/proxy (4.4.2)
  - Downloading fruitcake/php-cors (v1.2.0)
  - Downloading fruitcake/laravel-cors (v3.0.0)
  - Downloading guzzlehttp/promises (2.0.0)
  - Downloading symfony/yaml (v6.3.0)
  - Downloading laravel/sail (v1.22.0)
  - Downloading nikic/php-parser (v4.15.5)
  - Downloading psy/psysh (v0.11.18)
  - Downloading laravel/tinker (v2.8.1)
  - Downloading hamcrest/hamcrest-php (v2.0.1)
  - Downloading mockery/mockery (1.6.1)
  - Downloading filp/whoops (2.15.2)
  - Downloading nunomaduro/collision (v5.11.0)
  - Downloading sebastian/version (3.0.2)
  - Downloading sebastian/type (3.2.1)
  - Downloading sebastian/resource-operations (3.0.3)
  - Downloading sebastian/recursion-context (4.0.5)
  - 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.5)
  - Downloading sebastian/diff (4.0.5)
  - 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 theseer/tokenizer (1.2.1)
  - 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.26)
  - Downloading phar-io/version (3.2.1)
  - Downloading phar-io/manifest (2.0.3)
  - Downloading myclabs/deep-copy (1.11.1)
  - Downloading doctrine/instantiator (2.0.0)
  - Downloading phpunit/phpunit (9.6.8)
  - Downloading psr/http-message (1.1)
  - Downloading psr/http-factory (1.0.2)
  - Downloading ralouphie/getallheaders (3.0.3)
  - Downloading psr/http-client (1.0.2)
  - Downloading guzzlehttp/psr7 (2.5.0)
  - Downloading guzzlehttp/guzzle (7.7.0)
  - Downloading firebase/php-jwt (v6.5.0)
  - Downloading shopify/shopify-api (v5.0.0)
  - Downloading squizlabs/php_codesniffer (3.7.2)
  - Installing brick/math (0.11.0): Extracting archive
  - Installing psr/log (2.0.0): Extracting archive
  - Installing psr/cache (3.0.0): Extracting archive
  - Installing doctrine/event-manager (2.0.0): Extracting archive
  - Installing doctrine/deprecations (v1.1.1): Extracting archive
  - Installing doctrine/cache (2.2.0): Extracting archive
  - Installing doctrine/dbal (3.6.3): Extracting archive
  - Installing doctrine/lexer (1.2.3): Extracting archive
  - Installing symfony/polyfill-ctype (v1.27.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.27.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.27.0): Extracting archive
  - Installing symfony/var-dumper (v5.4.24): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.27.0): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.27.0): Extracting archive
  - Installing symfony/string (v6.3.0): Extracting archive
  - Installing symfony/deprecation-contracts (v3.3.0): Extracting archive
  - Installing psr/container (1.1.2): Extracting archive
  - Installing symfony/service-contracts (v2.5.2): Extracting archive
  - Installing symfony/polyfill-php73 (v1.27.0): Extracting archive
  - Installing symfony/console (v5.4.24): Extracting archive
  - Installing monolog/monolog (2.9.1): Extracting archive
  - Installing voku/portable-ascii (1.6.1): Extracting archive
  - Installing phpoption/phpoption (1.9.1): Extracting archive
  - Installing graham-campbell/result-type (v1.1.1): Extracting archive
  - Installing vlucas/phpdotenv (v5.5.0): Extracting archive
  - Installing symfony/css-selector (v6.3.0): Extracting archive
  - Installing tijsverkoyen/css-to-inline-styles (2.2.6): Extracting archive
  - Installing symfony/routing (v5.4.22): Extracting archive
  - Installing symfony/process (v5.4.24): Extracting archive
  - Installing symfony/polyfill-php72 (v1.27.0): Extracting archive
  - Installing symfony/polyfill-intl-idn (v1.27.0): Extracting archive
  - Installing symfony/mime (v5.4.23): Extracting archive
  - Installing symfony/http-foundation (v5.4.24): Extracting archive
  - Installing psr/event-dispatcher (1.0.0): Extracting archive
  - Installing symfony/event-dispatcher-contracts (v3.3.0): Extracting archive
  - Installing symfony/event-dispatcher (v6.3.0): Extracting archive
  - Installing symfony/error-handler (v5.4.24): Extracting archive
  - Installing symfony/http-kernel (v5.4.24): Extracting archive
  - Installing symfony/finder (v5.4.21): Extracting archive
  - Installing symfony/polyfill-iconv (v1.27.0): Extracting archive
  - Installing egulias/email-validator (2.1.25): Extracting archive
  - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive
  - Installing ramsey/collection (2.0.0): Extracting archive
  - Installing ramsey/uuid (4.7.4): Extracting archive
  - Installing psr/simple-cache (1.0.1): Extracting archive
  - Installing opis/closure (3.6.3): Extracting archive
  - Installing symfony/translation-contracts (v3.3.0): Extracting archive
  - Installing symfony/translation (v6.3.0): Extracting archive
  - Installing nesbot/carbon (2.67.0): Extracting archive
  - Installing league/mime-type-detection (1.11.0): Extracting archive
  - Installing league/flysystem (1.1.10): Extracting archive
  - Installing nette/utils (v4.0.0): Extracting archive
  - Installing nette/schema (v1.2.3): Extracting archive
  - Installing dflydev/dot-access-data (v3.0.2): Extracting archive
  - Installing league/config (v1.2.0): Extracting archive
  - Installing league/commonmark (2.4.0): Extracting archive
  - Installing laravel/serializable-closure (v1.3.0): Extracting archive
  - Installing doctrine/inflector (2.0.6): Extracting archive
  - Installing laravel/framework (v8.83.27): 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.7): Extracting archive
  - Installing fakerphp/faker (v1.22.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 (2.0.0): Extracting archive
  - Installing symfony/yaml (v6.3.0): Extracting archive
  - Installing laravel/sail (v1.22.0): Extracting archive
  - Installing nikic/php-parser (v4.15.5): Extracting archive
  - Installing psy/psysh (v0.11.18): Extracting archive
  - Installing laravel/tinker (v2.8.1): Extracting archive
  - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
  - Installing mockery/mockery (1.6.1): Extracting archive
  - Installing filp/whoops (2.15.2): Extracting archive
  - Installing nunomaduro/collision (v5.11.0): Extracting archive
  - Installing sebastian/version (3.0.2): Extracting archive
  - Installing sebastian/type (3.2.1): Extracting archive
  - Installing sebastian/resource-operations (3.0.3): Extracting archive
  - Installing sebastian/recursion-context (4.0.5): 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.5): Extracting archive
  - Installing sebastian/diff (4.0.5): 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 phpunit/php-invoker (3.1.1): Extracting archive
  - Installing phpunit/php-file-iterator (3.0.6): 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.26): 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.1): Extracting archive
  - Installing doctrine/instantiator (2.0.0): Extracting archive
  - Installing phpunit/phpunit (9.6.8): Extracting archive
  - Installing psr/http-message (1.1): Extracting archive
  - Installing psr/http-factory (1.0.2): Extracting archive
  - Installing ralouphie/getallheaders (3.0.3): Extracting archive
  - Installing psr/http-client (1.0.2): Extracting archive
  - Installing guzzlehttp/psr7 (2.5.0): Extracting archive
  - Installing guzzlehttp/guzzle (7.7.0): Extracting archive
  - Installing firebase/php-jwt (v6.5.0): Extracting archive
  - Installing shopify/shopify-api (v5.0.0): Extracting archive
  - Installing squizlabs/php_codesniffer (3.7.2): Extracting archive
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
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
 
In Process.php line 146:
 
  The Process class relies on proc_open, which is not available on your PHP installation.
 
 
install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [&lt;packages>...]
 
 

18、参考:Jenkins 构建镜像时,报错:The Process class relies on proc_open, which is not available on your PHP installation.的解决 。 编辑 /usr/local/php/etc/php.ini,在 disable_functions 中删除 proc_open、proc_get_status


disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen

[root@iZ23wv7v5ggZ php]# service php-fpm restart
Redirecting to /bin/systemctl restart php-fpm.service
[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
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!



19、执行数据库迁移时失败,报错:SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes


[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# php artisan migrate
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migration table created successfully.
Migrating: 2019_08_19_000000_create_failed_jobs_table

   Illuminate\Database\QueryException

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `failed_jobs` add unique `failed_jobs_uuid_unique`(`uuid`))

  at 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▕     }

      +9 vendor frames
  10  database/migrations/2019_08_19_000000_create_failed_jobs_table.php:24
      Illuminate\Support\Facades\Facade::__callStatic()

      +22 vendor frames
  33  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()


20、参考:阿里云RDS的参数配置,启用Innodb_large_prefix 。编辑 config/database.php,修改 ‘engine’ => null, 为 ‘engine’ => ‘InnoDB’,。再次执行数据库迁移,报错。SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘failed_jobs’ already exists。在数据库中删除掉所有表后,重新执行迁移。不再报错。


[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# php artisan migrate
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migration table created successfully.
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated:  2019_08_19_000000_create_failed_jobs_table (13.03ms)
Migrating: 2021_05_03_050717_create_sessions_table
Migrated:  2021_05_03_050717_create_sessions_table (11.62ms)
Migrating: 2021_05_05_071311_add_scope_expires_access_token_to_sessions
Migrated:  2021_05_05_071311_add_scope_expires_access_token_to_sessions (9.72ms)
Migrating: 2021_05_11_151158_add_online_access_info_to_sessions
Migrated:  2021_05_11_151158_add_online_access_info_to_sessions (9.32ms)
Migrating: 2021_05_17_152611_change_sessions_user_id_type
Migrated:  2021_05_17_152611_change_sessions_user_id_type (48.28ms)



21、构建后端。


[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# composer build
> composer build-frontend-links
> ln -sf ../frontend/dist/assets public/assets &amp;&amp; ln -sf ../frontend/dist/index.html public/index.html



22、访问应用首页:https://learn-php-app-0605-prod.shuijingwanwq.com/ 。响应 403。如图6

访问应用首页:https://learn-php-app-0605-prod.shuijingwanwq.com/ 。响应 403

图6

23、查看虚拟主机配置文件


[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# cat /usr/local/nginx/conf/vhost/learn-php-app-0605-prod.shuijingwanwq.com.conf
server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate /usr/local/nginx/conf/ssl/learn-php-app-0605-prod.shuijingwanwq.com.crt;
  ssl_certificate_key /usr/local/nginx/conf/ssl/learn-php-app-0605-prod.shuijingwanwq.com.key;
  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
  ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256;
  ssl_conf_command Ciphersuites TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256;
  ssl_conf_command Options PrioritizeChaCha;
  ssl_prefer_server_ciphers on;
  ssl_session_timeout 10m;
  ssl_session_cache shared:SSL:10m;
  ssl_buffer_size 2k;
  add_header Strict-Transport-Security max-age=15768000;
  ssl_stapling on;
  ssl_stapling_verify on;
  server_name learn-php-app-0605-prod.shuijingwanwq.com;
  access_log /data/wwwlogs/learn-php-app-0605-prod.shuijingwanwq.com_nginx.log combined;
  index index.html index.htm index.php;
  root /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com;
  if ($ssl_protocol = "") { return 301 https://$host$request_uri; }

  include /usr/local/nginx/conf/rewrite/laravel.conf;
  #error_page 404 /404.html;
  #error_page 502 /502.html;
  location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv|mp4)$ {
    valid_referers none blocked *.shuijingwanwq.com learn-php-app-0605-prod.shuijingwanwq.com;
    if ($invalid_referer) {
        return 403;
    }
  }
  location ~ [^/]\.php(/|$) {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
  }

  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log off;
  }
  location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
  }
  location ~ /(\.user\.ini|\.ht|\.git|\.svn|\.project|LICENSE|README\.md) {
    deny all;
  }
  location /.well-known {
    allow all;
  }
}
[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# ^C
[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]# cat /usr/local/nginx/conf/rewrite/laravel.conf
location / {
  try_files $uri $uri/ /index.php?$query_string;
}
[root@iZ23wv7v5ggZ learn-php-app-0605-prod.shuijingwanwq.com]#



24、参考模板中的 nginx.conf,其内容如下


user www-data www-data;

events {
    worker_connections 1024;
}

http {
    index index.php index.html;

    upstream php {
        server 127.0.0.1:9000;
    }

    server {
        include /etc/nginx/mime.types;
        include /etc/nginx/default.d/*.conf;

        listen PORT;
        server_name 0.0.0.0;
        root /app/public;

        location / {
            try_files $uri $uri/ /index.php?$args;
        }

        location ~ [^/]\.php(/|$) {
            include /etc/nginx/fastcgi_params;

            try_files $uri $uri/ /index.php?$uri;

            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO       $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

            fastcgi_pass   php;
            fastcgi_index  index.php;
        }
    }
}


25、编辑 /usr/local/nginx/conf/vhost/learn-php-app-0605-prod.shuijingwanwq.com.conf


  index index.php index.html;
  root /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com/public;


26、响应 500,开启 debug,编辑 .env。报错:TypeError
Shopify\Utils::sanitizeShopDomain(): Argument #1 ($shop) must be of type string, null given, called in /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com/app/Lib/AuthRedirection.php on line 17 。不用理会,符合预期。如图7

报错:TypeErrorShopify\Utils::sanitizeShopDomain(): Argument #1 ($shop) must be of type string, null given, called in /data/wwwroot/learn-php-app-0605-prod.shuijingwanwq.com/app/Lib/AuthRedirection.php on line 17

图7


APP_ENV=local
APP_DEBUG=true


27、更新合作伙伴仪表板中的 URL。如图8

更新合作伙伴仪表板中的 URL

图8

28、在合作伙伴仪表板中,转到应用程序的概览页面。在“测试您的应用”部分中,单击“选择商店”,然后选择一个商店来测试应用。如图9

在合作伙伴仪表板中,转到应用程序的概览页面。在“测试您的应用”部分中,单击“选择商店”,然后选择一个商店来测试应用

图9

29、安装应用时,报错:ops, something went wrong. 。原因应该在于请求参数有误。如图10

安装应用时,报错:ops, something went wrong. 。原因应该在于请求参数有误

图10


client_id: not_defined
scope: not_defined
redirect_uri: https://not_defined/api/auth/callback
state: b27be356-0010-43ae-b3b8-90a337314c0c
grant_options[]: 


30、编辑 .env,参考 .env.testing


APP_NAME="Shopify PHP App 0605 Prod"
APP_ENV=production
APP_KEY=base64:tPbLjWcISYL3Z/HS+OQS2GXvMPb0A7GlvNv6iFwFG6A=
APP_DEBUG=false
APP_URL=https://learn-php-app-0605-prod.shuijingwanwq.com

SHOPIFY_API_KEY=c7f826670575f7ae069f7e56350465ef
SHOPIFY_API_SECRET=4de64aa8281e97055cf7698bbe56039e
SCOPES=write_products
HOST=learn-php-app-0605-prod.shuijingwanwq.com

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=**************
DB_PORT=3306
DB_DATABASE=learn_php_app_0605_prod
DB_USERNAME=learn_php_app_0605_prod
DB_PASSWORD=*********



31、不再报错。如图11

不再报错

图11

32、点击安装应用后,进入店铺后台,但是页面预览为空白。如图12

点击安装应用后,进入店铺后台,但是页面预览为空白

图12

33、重新构建前端与后端后,卸载应用。如图13

重新构建前端与后端后,卸载应用

图13

34、再次安装,刷新页面,页面不再空白,符合预期。如图14

再次安装,刷新页面,页面不再空白,符合预期

图14

]]>
https://www.shuijingwanwq.com/2023/07/13/7855/feed/ 1
在 WSL2 中的 Ubuntu-20.04 中创建应用:Shopify App Template – PHP https://www.shuijingwanwq.com/2023/07/01/7792/ https://www.shuijingwanwq.com/2023/07/01/7792/#comments Sat, 01 Jul 2023 02:06:44 +0000 https://www.shuijingwanwq.com/?p=7792 浏览量: 268

1、参考:在 WSL2 中的 Ubuntu-20.04 中安装 Shopify CLI 3.0(基于 Node.js),提前检查相应的要求是否满足

2、创建应用,选择 PHP 模板,报错:operation not permitted, copyfile

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app$ npm init @shopify/app@latest
Need to install the following packages:
  @shopify/create-app@3.46.2
Ok to proceed? (y)

Welcome. Let’s get started by naming your app project. You can change it later.

?  Your app project name?
✔  learn-php-app-ubuntu-2004-0602

?  Which template would you like to use?
✔  php


╭─ error ──────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  EPERM: operation not permitted, copyfile                                    │
│  '/tmp/cb635eef29c31a10687f90a7693d4848/app/web/storage/logs/.gitignore' ->  │
│   '/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web/storage/lo  │
│  gs/.gitignore'                                                              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

npm notice
npm notice New minor version of npm available! 9.5.1 -> 9.6.7
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.7
npm notice Run npm install -g npm@9.6.7 to update!
npm notice
npm ERR! code 1
npm ERR! path /mnt/e/wwwroot/shopify-app
npm ERR! command failed
npm ERR! command sh -c create-app

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/wangqiang/.npm/_logs/2023-06-02T03_46_50_520Z-debug-0.log
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app$

3、在命令 npm init @shopify/app@latest 前添加 sudo,以提升权限,不再报错

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app$ sudo npm init @shopify/app@latest

Welcome. Let’s get started by naming your app project. You can change it later.

?  Your app project name?
✔  learn-php-app-ubuntu-2004-0602

?  Which template would you like to use?
✔  php

4、参考:安装 PHP 、Composer

wangqiang@DESKTOP-QLPK8QM:~$ sudo apt install php
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfwupdplugin1 libxmlb1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3
  libaprutil1-ldap libjansson4 liblua5.2-0 php-common php7.4 php7.4-cli php7.4-common php7.4-json php7.4-opcache
  php7.4-readline ssl-cert
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3
Enabling module status.
Enabling module reqtimeout.
Enabling conf charset.
Enabling conf localized-error-pages.
Enabling conf other-vhosts-access-log.
Enabling conf security.
Enabling conf serve-cgi-bin.
Enabling site 000-default.
info: Switch to mpm prefork for package libapache2-mod-php7.4
Module mpm_event disabled.
Enabling module mpm_prefork.
info: Executing deferred 'a2enmod php7.4' for package libapache2-mod-php7.4
Enabling module php7.4.
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
invoke-rc.d: could not determine current runlevel
Setting up php7.4 (7.4.3-4ubuntu2.18) ...
Setting up php (2:7.4+75) ...
Processing triggers for ufw (0.36-6ubuntu1) ...
Processing triggers for systemd (245.4-4ubuntu3.21) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
/sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link

Processing triggers for php7.4-cli (7.4.3-4ubuntu2.18) ...
Processing triggers for libapache2-mod-php7.4 (7.4.3-4ubuntu2.18) ...
wangqiang@DESKTOP-QLPK8QM:~$ sudo apt install composer
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfwupdplugin1 libxmlb1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  jsonlint libonig5 php-composer-ca-bundle php-composer-semver php-composer-spdx-licenses php-composer-xdebug-handler
  php-json-schema php-mbstring php-psr-container php-psr-log php-symfony-console php-symfony-filesystem
  php-symfony-finder php-symfony-process php-symfony-service-contracts php7.4-mbstring
Preparing to unpack .../16-composer_1.10.1-1_all.deb ...
Unpacking composer (1.10.1-1) ...
Setting up php-symfony-finder (4.3.8+dfsg-1ubuntu1) ...
Setting up jsonlint (1.7.2-1) ...
Setting up php-psr-container (1.0.0-2) ...
Setting up php-symfony-service-contracts (1.1.8-1) ...
Setting up php-composer-ca-bundle (1.2.6-1) ...
Setting up php-symfony-process (4.3.8+dfsg-1ubuntu1) ...
Setting up php-symfony-filesystem (4.3.8+dfsg-1ubuntu1) ...
Setting up php-psr-log (1.1.2-1) ...
Setting up php-composer-semver (1.5.1-1) ...
Setting up php-json-schema (5.2.9-1) ...
Setting up php-composer-spdx-licenses (1.5.3-1) ...
Setting up libonig5:amd64 (6.9.4-1) ...
Setting up php-composer-xdebug-handler (1.4.0-1) ...
Setting up php7.4-mbstring (7.4.3-4ubuntu2.18) ...

Creating config file /etc/php/7.4/mods-available/mbstring.ini with new version
Setting up php-mbstring (2:7.4+75) ...
Setting up php-symfony-console (4.3.8+dfsg-1ubuntu1) ...
Setting up composer (1.10.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
/sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link

Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libapache2-mod-php7.4 (7.4.3-4ubuntu2.18) ...
Processing triggers for php7.4-cli (7.4.3-4ubuntu2.18) ...

5、创建应用程序后,设置 Laravel 应用程序。安装依赖包。提示:建议升级至 Composer 2。先卸载掉 Composer 1,再安装 Composer 2 。参考:后续使用:php composer.phar

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ composer install
Loading composer repositories with package information
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ composer -V
Composer 1.10.1 2020-03-13 20:34:27
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt-get remove composer
[sudo] password for wangqiang:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  jsonlint libfwupdplugin1 libonig5 libxmlb1 php-composer-ca-bundle php-composer-semver php-composer-spdx-licenses
  php-composer-xdebug-handler php-json-schema php-mbstring php-psr-container php-psr-log php-symfony-console
  php-symfony-filesystem php-symfony-finder php-symfony-process php-symfony-service-contracts php7.4-mbstring
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  composer
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 1996 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 66661 files and directories currently installed.)
Removing composer (1.10.1-1) ...
Processing triggers for man-db (2.9.1-1) ...
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ composer -V
-bash: /usr/bin/composer: No such file or directory
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ php composer-setup.php
All settings correct for using Composer
Downloading...

Composer (version 2.5.7) successfully installed to: /mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web/composer.phar
Use it: php composer.phar
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ php composer.phar -V
Composer version 2.5.7 2023-05-24 15:00:39

6、提示:Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ php composer.phar install
Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ apt-cache search php | grep cur
l
php-curl - CURL module for PHP [default]
php7.4-curl - CURL module for PHP
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt-get install php-curl
[sudo] password for wangqiang:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  jsonlint libfwupdplugin1 libonig5 libxmlb1 php-composer-ca-bundle php-composer-semver php-composer-spdx-licenses
  php-composer-xdebug-handler php-json-schema php-mbstring php-psr-container php-psr-log php-symfony-console
  php-symfony-filesystem php-symfony-finder php-symfony-process php-symfony-service-contracts php7.4-mbstring
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  php7.4-curl
The following NEW packages will be installed:
  php-curl php7.4-curl
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 32.9 kB of archives.
After this operation, 148 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 php7.4-curl amd64 7.4.3-4ubuntu2.18 [30.9 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 php-curl all 2:7.4+75 [2000 B]
Fetched 32.9 kB in 2s (16.1 kB/s)
Selecting previously unselected package php7.4-curl.
(Reading database ... 66332 files and directories currently installed.)
Preparing to unpack .../php7.4-curl_7.4.3-4ubuntu2.18_amd64.deb ...
Unpacking php7.4-curl (7.4.3-4ubuntu2.18) ...
Selecting previously unselected package php-curl.
Preparing to unpack .../php-curl_2%3a7.4+75_all.deb ...
Unpacking php-curl (2:7.4+75) ...
Setting up php7.4-curl (7.4.3-4ubuntu2.18) ...

Creating config file /etc/php/7.4/mods-available/curl.ini with new version
Setting up php-curl (2:7.4+75) ...
Processing triggers for libapache2-mod-php7.4 (7.4.3-4ubuntu2.18) ...
Processing triggers for php7.4-cli (7.4.3-4ubuntu2.18) ...

7、Your requirements could not be resolved to an installable set of packages. 根 composer.json 需要 php ~8.0.0 || ~8.1.0 || ~8.2.0 但您的 php 版本 (7.4.3) 不满足该要求。一些必需的扩展也没有启用。

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ php composer.phar 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
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires php ~8.0.0 || ~8.1.0 || ~8.2.0 but your php version (7.4.3) does not satisfy that requirement.
  Problem 2
    - Root composer.json requires PHP extension ext-xml * but it is missing from your system. Install or enable PHP's xml extension.
  Problem 3
    - Root composer.json requires PHP extension ext-zip * but it is missing from your system. Install or enable PHP's zip extension.
  Problem 4
    - Root composer.json requires shopify/shopify-api ^5.0 -> satisfiable by shopify/shopify-api[v5.0.0].
    - shopify/shopify-api v5.0.0 requires php ~8.0.0 || ~8.1.0 || ~8.2.0 -> your php version (7.4.3) does not satisfy that requirement.
  Problem 5
    - Root composer.json requires squizlabs/php_codesniffer ^3.6 -> satisfiable by squizlabs/php_codesniffer[3.6.0, ..., 3.x-dev].
    - squizlabs/php_codesniffer[3.6.0, ..., 3.x-dev] require ext-xmlwriter * -> it is missing from your system. Install or enable PHP's xmlwriter extension.
  Problem 6
    - phpunit/phpunit[9.3.3, ..., 9.6.x-dev] require ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
    - Root composer.json requires phpunit/phpunit ^9.3.3 -> satisfiable by phpunit/phpunit[9.3.3, ..., 9.6.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.4/cli/php.ini
    - /etc/php/7.4/cli/conf.d/10-opcache.ini
    - /etc/php/7.4/cli/conf.d/10-pdo.ini
    - /etc/php/7.4/cli/conf.d/20-calendar.ini
    - /etc/php/7.4/cli/conf.d/20-ctype.ini
    - /etc/php/7.4/cli/conf.d/20-curl.ini
    - /etc/php/7.4/cli/conf.d/20-exif.ini
    - /etc/php/7.4/cli/conf.d/20-ffi.ini
    - /etc/php/7.4/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.4/cli/conf.d/20-ftp.ini
    - /etc/php/7.4/cli/conf.d/20-gettext.ini
    - /etc/php/7.4/cli/conf.d/20-iconv.ini
    - /etc/php/7.4/cli/conf.d/20-json.ini
    - /etc/php/7.4/cli/conf.d/20-mbstring.ini
    - /etc/php/7.4/cli/conf.d/20-phar.ini
    - /etc/php/7.4/cli/conf.d/20-posix.ini
    - /etc/php/7.4/cli/conf.d/20-readline.ini
    - /etc/php/7.4/cli/conf.d/20-shmop.ini
    - /etc/php/7.4/cli/conf.d/20-sockets.ini
    - /etc/php/7.4/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.4/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.4/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.4/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-xml --ignore-platform-req=ext-zip --ignore-platform-req=ext-xmlwriter --ignore-platform-req=ext-dom` to temporarily ignore these required extensions.

8、参考:在 WSL2 中的 Ubuntu-20.04 中卸载 PHP 7.4,然后安装 PHP 8 

9、继续安装 Composer 依赖

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt-get install php8.1-curl
[sudo] password for wangqiang:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  php8.1-curl
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 33.6 kB of archives.
After this operation, 152 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.1-curl amd64 8.1.18-1+ubuntu20.04.1+deb.sury.org+1 [33.6 kB]
Fetched 33.6 kB in 2s (21.8 kB/s)
Selecting previously unselected package php8.1-curl.
(Reading database ... 65958 files and directories currently installed.)
Preparing to unpack .../php8.1-curl_8.1.18-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.1-curl (8.1.18-1+ubuntu20.04.1+deb.sury.org+1) ...
Setting up php8.1-curl (8.1.18-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.1/mods-available/curl.ini with new version
Processing triggers for libapache2-mod-php8.1 (8.1.18-1+ubuntu20.04.1+deb.sury.org+1) ...
Processing triggers for php8.1-cli (8.1.18-1+ubuntu20.04.1+deb.sury.org+1) ...
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ php composer.phar 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
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires PHP extension ext-xml * but it is missing from your system. Install or enable PHP's xml extension.
  Problem 2
    - Root composer.json requires PHP extension ext-zip * but it is missing from your system. Install or enable PHP's zip extension.
  Problem 3
    - Root composer.json requires squizlabs/php_codesniffer ^3.6 -> satisfiable by squizlabs/php_codesniffer[3.6.0, ..., 3.x-dev].
    - squizlabs/php_codesniffer[3.6.0, ..., 3.x-dev] require ext-xmlwriter * -> it is missing from your system. Install or enable PHP's xmlwriter extension.
  Problem 4
    - phpunit/phpunit[9.3.3, ..., 9.6.x-dev] require ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
    - Root composer.json requires phpunit/phpunit ^9.3.3 -> satisfiable by phpunit/phpunit[9.3.3, ..., 9.6.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/8.1/cli/php.ini
    - /etc/php/8.1/cli/conf.d/10-opcache.ini
    - /etc/php/8.1/cli/conf.d/10-pdo.ini
    - /etc/php/8.1/cli/conf.d/20-calendar.ini
    - /etc/php/8.1/cli/conf.d/20-ctype.ini
    - /etc/php/8.1/cli/conf.d/20-curl.ini
    - /etc/php/8.1/cli/conf.d/20-exif.ini
    - /etc/php/8.1/cli/conf.d/20-ffi.ini
    - /etc/php/8.1/cli/conf.d/20-fileinfo.ini
    - /etc/php/8.1/cli/conf.d/20-ftp.ini
    - /etc/php/8.1/cli/conf.d/20-gettext.ini
    - /etc/php/8.1/cli/conf.d/20-iconv.ini
    - /etc/php/8.1/cli/conf.d/20-phar.ini
    - /etc/php/8.1/cli/conf.d/20-posix.ini
    - /etc/php/8.1/cli/conf.d/20-readline.ini
    - /etc/php/8.1/cli/conf.d/20-shmop.ini
    - /etc/php/8.1/cli/conf.d/20-sockets.ini
    - /etc/php/8.1/cli/conf.d/20-sysvmsg.ini
    - /etc/php/8.1/cli/conf.d/20-sysvsem.ini
    - /etc/php/8.1/cli/conf.d/20-sysvshm.ini
    - /etc/php/8.1/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-xml --ignore-platform-req=ext-zip --ignore-platform-req=ext-xmlwriter --ignore-platform-req=ext-dom` to temporarily ignore these required extensions.
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt-get install php8.1-xml
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt-get install php8.1-zip
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo php compos
er.phar install
[sudo] password for wangqiang:
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 114 installs, 0 updates, 0 removals
  - Downloading brick/math (0.11.0)
  - Downloading psr/log (2.0.0)
  - Downloading psr/cache (3.0.0)
  - Downloading doctrine/event-manager (2.0.0)
  - Downloading doctrine/deprecations (v1.1.0)
  - Downloading doctrine/cache (2.2.0)
  - Downloading doctrine/dbal (3.6.2)
  - Downloading doctrine/lexer (1.2.3)
  - Downloading symfony/polyfill-ctype (v1.27.0)
  - Downloading webmozart/assert (1.11.0)
  - Downloading dragonmantank/cron-expression (v3.3.2)
  - Downloading symfony/polyfill-php80 (v1.27.0)
  - Downloading symfony/polyfill-mbstring (v1.27.0)
  - Downloading symfony/var-dumper (v5.4.24)
  - Downloading symfony/polyfill-intl-normalizer (v1.27.0)
  - Downloading symfony/polyfill-intl-grapheme (v1.27.0)
  - Downloading symfony/string (v6.3.0)
  - Downloading symfony/deprecation-contracts (v3.3.0)
  - Downloading psr/container (1.1.2)
  - Downloading symfony/service-contracts (v2.5.2)
  - Downloading symfony/polyfill-php73 (v1.27.0)
  - Downloading symfony/console (v5.4.24)
  - Downloading monolog/monolog (2.9.1)
  - Downloading voku/portable-ascii (1.6.1)
  - Downloading phpoption/phpoption (1.9.1)
  - Downloading graham-campbell/result-type (v1.1.1)
  - Downloading vlucas/phpdotenv (v5.5.0)
  - Downloading symfony/css-selector (v6.3.0)
  - Downloading tijsverkoyen/css-to-inline-styles (2.2.6)
  - Downloading symfony/routing (v5.4.22)
  - Downloading symfony/process (v5.4.24)
  - Downloading symfony/polyfill-php72 (v1.27.0)
  - Downloading symfony/polyfill-intl-idn (v1.27.0)
  - Downloading symfony/mime (v5.4.23)
  - Downloading symfony/http-foundation (v5.4.24)
  - Downloading psr/event-dispatcher (1.0.0)
  - Downloading symfony/event-dispatcher-contracts (v3.3.0)
  - Downloading symfony/event-dispatcher (v6.3.0)
  - Downloading symfony/error-handler (v5.4.24)
  - Downloading symfony/http-kernel (v5.4.24)
  - Downloading symfony/finder (v5.4.21)
  - Downloading symfony/polyfill-iconv (v1.27.0)
  - Downloading egulias/email-validator (2.1.25)
  - Downloading swiftmailer/swiftmailer (v6.3.0)
  - Downloading ramsey/collection (2.0.0)
  - Downloading ramsey/uuid (4.7.4)
  - Downloading psr/simple-cache (1.0.1)
  - Downloading opis/closure (3.6.3)
  - Downloading symfony/translation-contracts (v3.3.0)
  - Downloading symfony/translation (v6.3.0)
  - Downloading nesbot/carbon (2.67.0)
  - Downloading league/mime-type-detection (1.11.0)
  - Downloading league/flysystem (1.1.10)
  - Downloading nette/utils (v4.0.0)
  - Downloading nette/schema (v1.2.3)
  - Downloading dflydev/dot-access-data (v3.0.2)
  - Downloading league/config (v1.2.0)
  - Downloading league/commonmark (2.4.0)
  - Downloading laravel/serializable-closure (v1.3.0)
  - Downloading doctrine/inflector (2.0.6)
  - Downloading laravel/framework (v8.83.27)
  - Downloading facade/ignition-contracts (1.0.2)
  - Downloading facade/flare-client-php (1.10.0)
  - Downloading facade/ignition (2.17.7)
  - Downloading fakerphp/faker (v1.22.0)
  - Downloading fideloper/proxy (4.4.2)
  - Downloading fruitcake/php-cors (v1.2.0)
  - Downloading fruitcake/laravel-cors (v3.0.0)
  - Downloading guzzlehttp/promises (2.0.0)
  - Downloading symfony/yaml (v6.3.0)
  - Downloading laravel/sail (v1.22.0)
  - Downloading nikic/php-parser (v4.15.5)
  - Downloading psy/psysh (v0.11.18)
  - Downloading laravel/tinker (v2.8.1)
  - Downloading hamcrest/hamcrest-php (v2.0.1)
  - Downloading mockery/mockery (1.5.1)
  - Downloading filp/whoops (2.15.2)
  - Downloading nunomaduro/collision (v5.11.0)
  - Downloading sebastian/version (3.0.2)
  - Downloading sebastian/type (3.2.1)
  - Downloading sebastian/resource-operations (3.0.3)
  - Downloading sebastian/recursion-context (4.0.5)
  - 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.5)
  - Downloading sebastian/diff (4.0.5)
  - 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 theseer/tokenizer (1.2.1)
  - 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.26)
  - Downloading phar-io/version (3.2.1)
  - Downloading phar-io/manifest (2.0.3)
  - Downloading myclabs/deep-copy (1.11.1)
  - Downloading doctrine/instantiator (2.0.0)
  - Downloading phpunit/phpunit (9.6.8)
  - Downloading psr/http-message (1.1)
  - Downloading psr/http-factory (1.0.2)
  - Downloading ralouphie/getallheaders (3.0.3)
  - Downloading psr/http-client (1.0.2)
  - Downloading guzzlehttp/psr7 (2.5.0)
  - Downloading guzzlehttp/guzzle (7.7.0)
  - Downloading firebase/php-jwt (v6.5.0)
  - Downloading shopify/shopify-api (v5.0.0)
  - Downloading squizlabs/php_codesniffer (3.7.2)
  - Installing brick/math (0.11.0): Extracting archive
  - Installing psr/log (2.0.0): Extracting archive
  - Installing psr/cache (3.0.0): Extracting archive
  - Installing doctrine/event-manager (2.0.0): Extracting archive
  - Installing doctrine/deprecations (v1.1.0): Extracting archive
  - Installing doctrine/cache (2.2.0): Extracting archive
  - Installing doctrine/dbal (3.6.2): Extracting archive
  - Installing doctrine/lexer (1.2.3): Extracting archive
  - Installing symfony/polyfill-ctype (v1.27.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.27.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.27.0): Extracting archive
  - Installing symfony/var-dumper (v5.4.24): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.27.0): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.27.0): Extracting archive
  - Installing symfony/string (v6.3.0): Extracting archive
  - Installing symfony/deprecation-contracts (v3.3.0): Extracting archive
  - Installing psr/container (1.1.2): Extracting archive
  - Installing symfony/service-contracts (v2.5.2): Extracting archive
  - Installing symfony/polyfill-php73 (v1.27.0): Extracting archive
  - Installing symfony/console (v5.4.24): Extracting archive
  - Installing monolog/monolog (2.9.1): Extracting archive
  - Installing voku/portable-ascii (1.6.1): Extracting archive
  - Installing phpoption/phpoption (1.9.1): Extracting archive
  - Installing graham-campbell/result-type (v1.1.1): Extracting archive
  - Installing vlucas/phpdotenv (v5.5.0): Extracting archive
  - Installing symfony/css-selector (v6.3.0): Extracting archive
  - Installing tijsverkoyen/css-to-inline-styles (2.2.6): Extracting archive
  - Installing symfony/routing (v5.4.22): Extracting archive
  - Installing symfony/process (v5.4.24): Extracting archive
  - Installing symfony/polyfill-php72 (v1.27.0): Extracting archive
  - Installing symfony/polyfill-intl-idn (v1.27.0): Extracting archive
  - Installing symfony/mime (v5.4.23): Extracting archive
  - Installing symfony/http-foundation (v5.4.24): Extracting archive
  - Installing psr/event-dispatcher (1.0.0): Extracting archive
  - Installing symfony/event-dispatcher-contracts (v3.3.0): Extracting archive
  - Installing symfony/event-dispatcher (v6.3.0): Extracting archive
  - Installing symfony/error-handler (v5.4.24): Extracting archive
  - Installing symfony/http-kernel (v5.4.24): Extracting archive
  - Installing symfony/finder (v5.4.21): Extracting archive
  - Installing symfony/polyfill-iconv (v1.27.0): Extracting archive
  - Installing egulias/email-validator (2.1.25): Extracting archive
  - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive
  - Installing ramsey/collection (2.0.0): Extracting archive
  - Installing ramsey/uuid (4.7.4): Extracting archive
  - Installing psr/simple-cache (1.0.1): Extracting archive
  - Installing opis/closure (3.6.3): Extracting archive
  - Installing symfony/translation-contracts (v3.3.0): Extracting archive
  - Installing symfony/translation (v6.3.0): Extracting archive
  - Installing nesbot/carbon (2.67.0): Extracting archive
  - Installing league/mime-type-detection (1.11.0): Extracting archive
  - Installing league/flysystem (1.1.10): Extracting archive
  - Installing nette/utils (v4.0.0): Extracting archive
  - Installing nette/schema (v1.2.3): Extracting archive
  - Installing dflydev/dot-access-data (v3.0.2): Extracting archive
  - Installing league/config (v1.2.0): Extracting archive
  - Installing league/commonmark (2.4.0): Extracting archive
  - Installing laravel/serializable-closure (v1.3.0): Extracting archive
  - Installing doctrine/inflector (2.0.6): Extracting archive
  - Installing laravel/framework (v8.83.27): 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.7): Extracting archive
  - Installing fakerphp/faker (v1.22.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 (2.0.0): Extracting archive
  - Installing symfony/yaml (v6.3.0): Extracting archive
  - Installing laravel/sail (v1.22.0): Extracting archive
  - Installing nikic/php-parser (v4.15.5): Extracting archive
  - Installing psy/psysh (v0.11.18): Extracting archive
  - Installing laravel/tinker (v2.8.1): Extracting archive
  - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
  - Installing mockery/mockery (1.5.1): Extracting archive
  - Installing filp/whoops (2.15.2): Extracting archive
  - Installing nunomaduro/collision (v5.11.0): Extracting archive
  - Installing sebastian/version (3.0.2): Extracting archive
  - Installing sebastian/type (3.2.1): Extracting archive
  - Installing sebastian/resource-operations (3.0.3): Extracting archive
  - Installing sebastian/recursion-context (4.0.5): 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.5): Extracting archive
  - Installing sebastian/diff (4.0.5): 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 phpunit/php-invoker (3.1.1): Extracting archive
  - Installing phpunit/php-file-iterator (3.0.6): 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.26): 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.1): Extracting archive
  - Installing doctrine/instantiator (2.0.0): Extracting archive
  - Installing phpunit/phpunit (9.6.8): Extracting archive
  - Installing psr/http-message (1.1): Extracting archive
  - Installing psr/http-factory (1.0.2): Extracting archive
  - Installing ralouphie/getallheaders (3.0.3): Extracting archive
  - Installing psr/http-client (1.0.2): Extracting archive
  - Installing guzzlehttp/psr7 (2.5.0): Extracting archive
  - Installing guzzlehttp/guzzle (7.7.0): Extracting archive
  - Installing firebase/php-jwt (v6.5.0): Extracting archive
  - Installing shopify/shopify-api (v5.0.0): Extracting archive
  - Installing squizlabs/php_codesniffer (3.7.2): Extracting archive
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
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!

10、安装 MySQL,参考:进入数据库

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo apt install mysql-server
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ mysql --version
mysql  Ver 8.0.33-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo /etc/init.d/mysql start
 * Starting MySQL database server mysqld                                                                su: warning: cannot change directory to /nonexistent: No such file or directory
                                                                                                 [ OK ]
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.33-0ubuntu0.20.04.2 (Ubuntu)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> CREATE DATABASE learn_php_app_ubuntu_2004_0602;
Query OK, 1 row affected (0.01 sec)

mysql> SHOW DATABASES;
+--------------------------------+
| Database                       |
+--------------------------------+
| information_schema             |
| learn_php_app_ubuntu_2004_0602 |
| mysql                          |
| performance_schema             |
| sys                            |
+--------------------------------+
5 rows in set (0.00 sec)

mysql>

11、编辑 .env

APP_NAME="Shopify PHP App Ubuntu-20.04"
APP_ENV=local
APP_KEY=
APP_DEBUG=true

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=learn_php_app_ubuntu_2004_0602
DB_USERNAME=
DB_PASSWORD=

12、执行数据库迁移命令时报错:Access denied for user ”@’localhost’ (using password: NO)

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ php artisan migrate

   Illuminate\Database\QueryException

  SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table_schema = learn_php_app_ubuntu_2004_0602 and table_name = migrations and table_type = 'BASE TABLE')

  at 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▕     }

      +33 vendor frames
  34  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

13、启动安全脚本提示符:sudo mysql_secure_installation 时,设置密码时提示:Failed! Error: SET PASSWORD has no significance for user ‘root’@’localhost’ as the authentication method used doesn’t store authentication data in the MySQL server.

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/web$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Please set the password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
 ... Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.

14、执行:sudo cat /etc/mysql/debian.cnf,使用文件中的用户名与密码重新设置 .env ,执行数据库迁移成功

APP_NAME="Shopify PHP App Ubuntu-20.04"
APP_ENV=local
APP_KEY=base64:YFa6CcsSTZ4d0u62FbrCmehnoEx9q9bM5OnqjnAxdeU=
APP_DEBUG=true

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=learn_php_app_ubuntu_2004_0602
DB_USERNAME=debian-sys-maint
DB_PASSWORD=nGWMLgJjXnsnhm7t

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602/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 (106.88ms)
Migrating: 2021_05_03_050717_create_sessions_table
Migrated:  2021_05_03_050717_create_sessions_table (45.18ms)
Migrating: 2021_05_05_071311_add_scope_expires_access_token_to_sessions
Migrated:  2021_05_05_071311_add_scope_expires_access_token_to_sessions (27.42ms)
Migrating: 2021_05_11_151158_add_online_access_info_to_sessions
Migrated:  2021_05_11_151158_add_online_access_info_to_sessions (23.57ms)
Migrating: 2021_05_17_152611_change_sessions_user_id_type
Migrated:  2021_05_17_152611_change_sessions_user_id_type (630.37ms)

15、启动本地服务器,回到根目录,执行:npm run dev,报错,怀疑是第 3 步骤未执行彻底导致的问题。因为在第 3 步骤未提示:success

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602$ npm run dev

> learn-php-app-ubuntu-2004-0602@1.0.0 dev
> shopify app dev

?  Command `app dev` not found. Did you mean `theme dev`?
✔  Yes, confirm

╭─ error ──────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  A store is required                                                         │
│                                                                              │
│  Specify the store passing --store={your_store_url} or set the               │
│  SHOPIFY_FLAG_STORE environment variable.                                    │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0602$

16、从头开始新建应用:learn-php-app-ubuntu-2004-0605,需要耐心等待一段时间,不要中途给中止了。如图1

从头开始新建应用:learn-php-app-ubuntu-2004-0605,需要耐心等待一段时间,不要中途给中止了

图1

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app$ sudo npm init @shopify/app@latest

Welcome. Let’s get started by naming your app project. You can change it later.

?  Your app project name?
✔  learn-php-app-ubuntu-2004-0605

?  Which template would you like to use?
✔  php


╭─ success ────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  learn-php-app-ubuntu-2004-0605 is ready for you to build!                   │
│                                                                              │
│  Next steps                                                                  │
│    • Run `cd learn-php-app-ubuntu-2004-0605`                                 │
│    • For extensions, run `npm run generate extension`                        │
│    • To see your app, run `npm run dev`                                      │
│                                                                              │
│  Reference                                                                   │
│    • Shopify docs [1]                                                        │
│    • For an overview of commands, run `npm run shopify app -- --help`        │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
[1] https://shopify.dev

17、再次从第 4 步骤开始操作,一些步骤可以跳过。执行第 15 步骤,报错:To investigate the issue, examine this stack trace。重新执行即可。进入安装应用。如图2

再次从第 4 步骤开始操作,一些步骤可以跳过。执行第 15 步骤,报错:To investigate the issue, examine this stack trace。重新执行即可。进入安装应用

图2

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605$ composer -V
Composer version 2.5.5 2023-03-21 11:50:05
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605/web$ composer install
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605/web$ cp .env.example .env
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605/web$ php artisan key:generate
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605/web$ php artisan migrate
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605$ npm run dev

> learn-php-app-ubuntu-2004-0605@1.0.0 dev
> shopify app dev


To run this command, log in to Shopify Partners.
👉 Press any key to open the login page on your browser

Auto-open timed out. Open the login page: Log in to Shopify Partners ( http://accounts.shopify.com/oauth/authorize?client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&scope=openid+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.admin.graphql+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.admin.themes+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshop.storefront-renderer.devtools+https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&redirect_uri=http%3A%2F%2F127.0.0.1%3A3456&state=5cba6732fe773fac2a7e9a95ddf3ab686b3a9b7231168d58f339f17dcaa1&response_type=code&code_challenge_method=S256&code_challenge=gozZ6hqQIOzwYdzxuX2RaOUgpaRz9A8gUlUoC6Wy6Vw )

✔ Logged in.

Looks like this is the first time you're running dev for this project.
Configure your preferences by answering a few questions.


Before you preview your work, it needs to be associated with an app.

?  Create this project as a new app on Shopify?
✔  Yes, create it as a new app

?  App name:
✔  learn-php-app-ubuntu-2004-0605

✔ Using your default dev store (shuijingwanwq-development) to preview your project.
╭─ error ──────────────────────────────────────────────────────────────────────╮
│                                                                              │
│                                                                              │
│  To investigate the issue, examine this stack trace:                         │
│    at pollTunnelStatus (@shopify/app/src/cli/services/dev/urls.ts:106)       │
│      if (result.status === 'error') return reject(new                        │
│      BugError(result.message))                                               │
│    at (@shopify/app/src/cli/services/dev/urls.ts:120)                        │
│      pollTunnelStatus()                                                      │
│    at new Promise                                                            │
│    at pollTunnelURL (@shopify/app/src/cli/services/dev/urls.ts:101)          │
│      return new Promise<string>((resolve, reject) => {                       │
│    at generateFrontendURL (@shopify/app/src/cli/services/dev/urls.ts:89)     │
│      const url = await pollTunnelURL(options.tunnelClient)                   │
│    at dev (@shopify/app/src/cli/services/dev.ts:121)                         │
│      generateFrontendURL({                                                   │
│    at run (@shopify/app/src/cli/commands/app/dev.ts:106)                     │
│      await dev({                                                             │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/shopify-app/learn-php-app-ubuntu-2004-0605$ npm run dev

> learn-php-app-ubuntu-2004-0605@1.0.0 dev
> shopify app dev

╭─ info ───────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  Using your previous dev settings:                                           │
│                                                                              │
│    • Org:          王强                                                      │
│    • App:          learn-php-app-ubuntu-2004-0605                            │
│    • Dev store:    shuijingwanwq-development.myshopify.com                   │
│    • Update URLs:  Not yet configured                                        │
│                                                                              │
│  To reset your default dev config, run `npm run dev -- --reset`              │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

?  Have Shopify automatically update your app's URL in order to create a preview experience?
✔  Always by default

2023-06-06 01:51:12 │ frontend │
2023-06-06 01:51:12 │ frontend │ > shopify-frontend-template-react@1.0.0 dev
2023-06-06 01:51:12 │ frontend │ > vite
2023-06-06 01:51:12 │ frontend │
2023-06-06 01:51:18 │ backend  │ > Composer\Config::disableProcessTimeout
2023-06-06 01:51:18 │ backend  │ > php artisan serve
2023-06-06 01:51:20 │ frontend │
2023-06-06 01:51:20 │ frontend │   VITE v4.3.9  ready in 7780 ms
2023-06-06 01:51:20 │ frontend │
2023-06-06 01:51:20 │ frontend │   ➜  Local:   http://localhost:33597/
2023-06-06 01:51:26 │ backend  │ Starting Laravel development server: http://127.0.0.1:44681
2023-06-06 01:51:27 │ backend  │ [Tue Jun  6 09:51:26 2023] PHP 8.1.18 Development Server (http://127.0.0.1:44681) started
2023-06-06 01:51:47 │ backend  │ [Tue Jun  6 09:51:47 2023] 127.0.0.1:34304 Accepted
2023-06-06 01:51:54 │ backend  │ [Tue Jun  6 09:51:54 2023] 127.0.0.1:34304 Closing
2023-06-06 01:51:54 │ backend  │ [Tue Jun  6 09:51:54 2023] 127.0.0.1:34310 Accepted
2023-06-06 01:51:56 │ backend  │ [Tue Jun  6 09:51:56 2023] 127.0.0.1:34310 Closing
2023-06-06 01:53:17 │ backend  │ [Tue Jun  6 09:53:17 2023] 127.0.0.1:34320 Accepted
2023-06-06 01:53:22 │ backend  │ [Tue Jun  6 09:53:22 2023] 127.0.0.1:34320 Closing
2023-06-06 01:53:22 │ backend  │ [Tue Jun  6 09:53:22 2023] 127.0.0.1:34326 Accepted
2023-06-06 01:53:26 │ backend  │ [Tue Jun  6 09:53:25 2023] 127.0.0.1:34326 Closing

› Press p │ preview in your browser
› Press q │ quit

Preview URL: https://instructional-attend-excellent-gig.trycloudflare.com?shop=shuijingwanwq-development.myshopify.com&h
ost=c2h1aWppbmd3YW53cS1kZXZlbG9wbWVudC5teXNob3BpZnkuY29tL2FkbWlu

18、安装应用时报错:Shopify\Exception\CookieNotFoundException Could not find the current session id in the cookies。如图3

安装应用时报错:Shopify\Exception\CookieNotFoundException Could not find the current session id in the cookies

图3

19、再次运行:npm run dev,打开浏览器,不再报错。如图4

再次运行:npm run dev,打开浏览器,不再报错

图4

]]>
https://www.shuijingwanwq.com/2023/07/01/7792/feed/ 1
在 PHP 7.4 中,针对 URI ,基于 league/uri 添加查询参数 https://www.shuijingwanwq.com/2023/06/02/7684/ https://www.shuijingwanwq.com/2023/06/02/7684/#respond Fri, 02 Jun 2023 01:14:34 +0000 https://www.shuijingwanwq.com/?p=7684 浏览量: 83 1、在 Laravel 6 中,基于判断字符串中是否包含 ?,有一个简单的实现


use Illuminate\Support\Str;

if (Str::contains($themeAwareUrlPath, '?')) {
	$suffix = '&';
} else {
	$suffix = '?';
}

return new HtmlString($prefix.$themeAwareUrlPath.$suffix.'d='.config('app.url'));


2、不过此实现,一些复杂的 URI 未考虑到。例:?d=3&e=5#6,会被替换为:?d=3&e=5#6&d=https://xxx.com 。 3、最终决定基于 league/uri 添加查询参数,执行 composer require league/uri-components、composer require league/uri 4、代码实现如下


use League\Uri\Uri;
use League\Uri\UriModifier;

$uri = Uri::createFromString($themeAwareUrlPath);
$cdnUri = UriModifier::mergeQuery($uri, 'd=' . config('app.url'));

return new HtmlString($prefix . $cdnUri->jsonSerialize());


5、基于一些常见的 URI ,替换后的结果如下,符合预期


$themeAwareUrlPath = '9919b10c-9217-44eb-8488-198a321067cc/assets/images/default-banner.64bbdd.jpg';

$themeAwareUrlPath .= '?a=3';
string(102) "9919b10c-9217-44eb-8488-198a321067cc/assets/images/default-banner.64bbdd.jpg?a=3&d=https://xxx.local"

$themeAwareUrlPath .= '?d=3';
string(98) "9919b10c-9217-44eb-8488-198a321067cc/assets/images/default-banner.64bbdd.jpg?d=https://xxx.local"

$themeAwareUrlPath .= '?d=3&e=5#6';
string(104) "9919b10c-9217-44eb-8488-198a321067cc/assets/images/default-banner.64bbdd.jpg?d=https://xxx.local&e=5#6"

$themeAwareUrlPath .= '?a=1&d=3&e=5#6';
string(108) "9919b10c-9217-44eb-8488-198a321067cc/assets/images/default-banner.64bbdd.jpg?a=1&d=https://xxx.local&e=5#6"

$themeAwareUrlPath .= '?#';
string(100) "9919b10c-9217-44eb-8488-198a321067cc/assets/images/default-banner.64bbdd.jpg?&d=https://xxx.local#"

$themeAwareUrlPath .= '?';
string(99) "9919b10c-9217-44eb-8488-198a321067cc/assets/images/default-banner.64bbdd.jpg?&d=https://xxx.local"


]]>
https://www.shuijingwanwq.com/2023/06/02/7684/feed/ 0
在执行 composer require 后,在 composer.lock 中,plugin-api-version 从 2.3.0 变化为 2.2.0 https://www.shuijingwanwq.com/2023/06/01/7679/ https://www.shuijingwanwq.com/2023/06/01/7679/#respond Thu, 01 Jun 2023 01:51:50 +0000 https://www.shuijingwanwq.com/?p=7679 浏览量: 88 1、在执行 composer require 后,在 composer.lock 中,plugin-api-version 从 2.3.0 变化为 2.2.0 。如图1
在执行 composer require 后,在 composer.lock 中,plugin-api-version 从 2.3.0 变化为 2.2.0

图1

2、文件中的 plugin-api-version 属性有助于确保依赖项和插件之间的兼容性,这对于保持稳定高效至关重要。决定尽量避免 plugin-api-version 的变化。执行 composer self-update,更新 composer 版本。如图2
文件中的 plugin-api-version 属性有助于确保依赖项和插件之间的兼容性,这对于保持稳定高效至关重要。决定尽量避免 plugin-api-version 的变化。执行 composer self-update,更新 composer 版本

图2



PS E:\wwwroot\xxx\platform> composer self-update
Upgrading to version 2.5.5 (stable channel).

Use composer self-update --rollback to return to version 2.2.6


3、再次执行 composer require 后,在 composer.lock 中,plugin-api-version 不再变化。如图3
再次执行 composer require 后,在 composer.lock 中,plugin-api-version 不再变化

图3

]]>
https://www.shuijingwanwq.com/2023/06/01/7679/feed/ 0
在 Laravel 6 中的模块(nWidart/laravel-modules:7.3)上定义调度任务 https://www.shuijingwanwq.com/2023/01/07/7330/ https://www.shuijingwanwq.com/2023/01/07/7330/#respond Sat, 07 Jan 2023 02:27:59 +0000 https://www.shuijingwanwq.com/?p=7330 浏览量: 237 1、生成一个新模块:Blog。


PS E:\wwwroot\laravel6-modules-demo> php artisan module:make Blog
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/module.json
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/Routes/web.php
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/Routes/api.php
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/Resources/views/index.blade.php
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/Resources/views/layouts/master.blade.php
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/Config/config.php
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/composer.json
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/Resources/assets/js/app.js
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/Resources/assets/sass/app.scss
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/webpack.mix.js
Created : E:\wwwroot\laravel6-modules-demo\Modules/Blog/package.json
Created : E:/wwwroot/laravel6-modules-demo/Modules/Blog/Database/Seeders/BlogDatabaseSeeder.php
Created : E:/wwwroot/laravel6-modules-demo/Modules/Blog/Providers/BlogServiceProvider.php
Created : E:/wwwroot/laravel6-modules-demo/Modules/Blog/Providers/RouteServiceProvider.php
Created : E:/wwwroot/laravel6-modules-demo/Modules/Blog/Http/Controllers/BlogController.php
Module [Blog] created successfully.


2、默认情况下,模块类不会自动加载。 你可以使用 psr-4 自动加载你的模块。编辑 composer.json。如图1
默认情况下,模块类不会自动加载。 你可以使用 psr-4 自动加载你的模块。编辑 composer.json

图1



    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Modules\\": "Modules/"
        }
    },


3、提示:不要忘记之后运行 composer dump-autoload。如图2
提示:不要忘记之后运行 composer dump-autoload

图2



PS E:\wwwroot\laravel6-modules-demo> composer dump-autoload
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nwidart/laravel-modules
Package manifest generated successfully.
Generated optimized autoload files containing 4360 classes


4、为指定模块生成给定的控制台命令。


PS E:\wwwroot\laravel6-modules-demo> php artisan module:make-command CreatePostCommand Blog
Created : E:/wwwroot/laravel6-modules-demo/Modules/Blog/Console/CreatePostCommand.php


5、编辑 CreatePostCommand.php,主要修改 $name 属性与 handle 方法
<pre class="wp-block-syntaxhighlighter-code">

<?php

namespace Modules\Blog\Console;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class CreatePostCommand extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'blog:create-post';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description.';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        file_put_contents(storage_path() . '/logs/Modules-Blog-Console-CreatePostCommand-handle-' . microtime(true) . '-' . mt_rand()  . '.txt', print_r([], true), FILE_APPEND | LOCK_EX);
    }

    /**
     * Get the console command arguments.
     *
     * @return array
     */
    protected function getArguments()
    {
        return [
            ['example', InputArgument::REQUIRED, 'An example argument.'],
        ];
    }

    /**
     * Get the console command options.
     *
     * @return array
     */
    protected function getOptions()
    {
        return [
            ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
        ];
    }
}


</pre>
6、注册命令,使用服务提供者类中可用的名为 commands 的 laravel 方法注册该命令。


    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->register(RouteServiceProvider::class);
        $this->commands([
            \Modules\Blog\Console\CreatePostCommand::class,
        ]);
    }


7、要查看所有可用的 Artisan 命令的列表,可以使用 list 命令:确认 blog:create-post 已存在。如图3
要查看所有可用的 Artisan 命令的列表,可以使用 list 命令:确认 blog:create-post 已存在

图3

8、执行:php artisan blog:create-post 时报错:Not enough arguments (missing: “example”).


PS E:\wwwroot\laravel6-modules-demo> php artisan blog:create-post


  Not enough arguments (missing: "example").




9、编辑 CreatePostCommand.php ,删除掉方法 getArguments 10、再次执行:php artisan blog:create-post,不再报错。查看执行结果,有输出日志文件:Modules-Blog-Console-CreatePostCommand-handle-1672371310.181-805184791.txt 。如图4
再次执行:php artisan blog:create-post,不再报错。查看执行结果,有输出日志文件:Modules-Blog-Console-CreatePostCommand-handle-1672371310.181-805184791.txt

图4

11、执行:php artisan schedule:run,响应:没有计划的命令准备好运行。


PS E:\wwwroot\laravel6-modules-demo> php artisan schedule:run
No scheduled commands are ready to run.


12、参考任务调度 – Artisan 命令调度,在 App\Console\Kernel 类的 schedule 方法中定义新的调度任务


    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();
        $schedule->command('blog:create-post')->everyMinute(); // 每分钟执行一次任务
    }


13、执行 schedule:run 命令 ,执行成功,且成功生成对应的日志文件。如图5
执行 schedule:run 命令 ,执行成功,且成功生成对应的日志文件

图5



PS E:\wwwroot\laravel6-modules-demo> php artisan schedule:run
Running scheduled command: "C:\php-7.4.27\php.exe" "artisan" blog:create-post > "NUL" 2>&1


14、但是,既然 command blog:create-post 是在模块中编写的,那么调度此 command 的 schedule 也应该在对应的模块中编写才是更为合适的实现。 15、参考:https://stackoverflow.com/questions/30456737/how-to-schedule-artisan-commands-in-a-package ,两种方案皆是可行的。还原第 12 步骤的实现。


    /**
     * Boot the application events.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerTranslations();
        $this->registerConfig();
        $this->registerViews();
        $this->registerFactories();
        $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
        /*
        $this->app->booted(function () {
            $schedule = $this->app->make(Schedule::class);
            $schedule->command('blog:create-post')->everyMinute();
        });
        */
        // 在 Laravel 6.10 及以上版本中:
        $this->callAfterResolving(Schedule::class, function (Schedule $schedule) {
            $schedule->command('blog:create-post')->everyMinute();
        });
    }




PS E:\wwwroot\laravel6-modules-demo> php artisan schedule:run
Running scheduled command: "C:\php-7.4.27\php.exe" "artisan" blog:create-post > "NUL" 2>&1
PS E:\wwwroot\laravel6-modules-demo> php artisan schedule:run
Running scheduled command: "C:\php-7.4.27\php.exe" "artisan" blog:create-post > "NUL" 2>&1


]]>
https://www.shuijingwanwq.com/2023/01/07/7330/feed/ 0
在 Laravel 6 中,报错:Cannot call Ramsey\Uuid\Converter\Number\DegradedNumberConverter::toHex without support for large integers, since integer is an unsigned 128-bit integer; Moontoast\Math\BigNumber is required. https://www.shuijingwanwq.com/2022/10/10/7038/ https://www.shuijingwanwq.com/2022/10/10/7038/#respond Mon, 10 Oct 2022 01:25:12 +0000 https://www.shuijingwanwq.com/?p=7038 浏览量: 72 1、在 Laravel 6 中,报错:E:\\wwwroot\\object\\vendor\\ramsey\\uuid\\src\\Converter\\Number\\DegradedNumberConverter.php”, “class”: “Ramsey\\Uuid\\Exception\\UnsatisfiedDependencyException 如图1
在 Laravel 6 中,报错:E:\\wwwroot\\object\\vendor\\ramsey\\uuid\\src\\Converter\\Number\\DegradedNumberConverter.php",         "class": "Ramsey\\Uuid\\Exception\\UnsatisfiedDependencyException

图1



{
    "message": "internal error",
    "status_code": 500,
    "debug": {
        "line": 52,
        "file": "E:\\wwwroot\\object\\vendor\\ramsey\\uuid\\src\\Converter\\Number\\DegradedNumberConverter.php",
        "class": "Ramsey\\Uuid\\Exception\\UnsatisfiedDependencyException",
        "trace": [
            "#0 E:\\wwwroot\\object\\vendor\\ramsey\\uuid\\src\\Generator\\CombGenerator.php(75): Ramsey\\Uuid\\Converter\\Number\\DegradedNumberConverter->toHex('166356881950642')",
            "#1 E:\\wwwroot\\object\\vendor\\ramsey\\uuid\\src\\UuidFactory.php(236): Ramsey\\Uuid\\Generator\\CombGenerator->generate(16)",
            "#2 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Str.php(666): Ramsey\\Uuid\\UuidFactory->uuid4()",
            "#3 E:\\wwwroot\\object\\Modules\\ThemeStoreDB\\Entities\\ThemeInstallation.php(63): Illuminate\\Support\\Str::orderedUuid()",
            "#4 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Concerns\\HasRelationships.php(718): Modules\\ThemeStoreDB\\Entities\\ThemeInstallation->__construct()",
            "#5 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Concerns\\HasRelationships.php(57): Illuminate\\Database\\Eloquent\\Model->newRelatedInstance('Modules\\\\ThemeSt...')",
            "#6 E:\\wwwroot\\object\\app\\Models\\Theme.php(202): Illuminate\\Database\\Eloquent\\Model->hasOne('Modules\\\\ThemeSt...', 'wp_theme_id')",
            "#7 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Builder.php(611): App\\Models\\Theme->themeInstallation()",
            "#8 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Relations\\Relation.php(90): Illuminate\\Database\\Eloquent\\Builder->Illuminate\\Database\\Eloquent\\{closure}()",
            "#9 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Builder.php(615): Illuminate\\Database\\Eloquent\\Relations\\Relation::noConstraints(Object(Closure))",
            "#10 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Builder.php(583): Illuminate\\Database\\Eloquent\\Builder->getRelation('themeInstallati...')",
            "#11 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Builder.php(563): Illuminate\\Database\\Eloquent\\Builder->eagerLoadRelation(Array, 'themeInstallati...', Object(Closure))",
            "#12 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Builder.php(531): Illuminate\\Database\\Eloquent\\Builder->eagerLoadRelations(Array)",
            "#13 E:\\wwwroot\\object\\app\\Services\\ThemeService.php(73): Illuminate\\Database\\Eloquent\\Builder->get()",
            "#14 E:\\wwwroot\\object\\app\\Http\\Controllers\\Admin\\API\\ThemeController.php(38): App\\Services\\ThemeService->list()",
            "#15 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(54): App\\Http\\Controllers\\Admin\\API\\ThemeController->index(Object(App\\Services\\ThemeService))",
            "#16 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('index', Array)",
            "#17 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\Admin\\API\\ThemeController), 'index')",
            "#18 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(176): Illuminate\\Routing\\Route->runController()",
            "#19 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(681): Illuminate\\Routing\\Route->run()",
            "#20 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(130): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#21 E:\\wwwroot\\object\\app\\Http\\Middleware\\RoleOrPermissionMiddleware.php(32): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#22 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): App\\Http\\Middleware\\RoleOrPermissionMiddleware->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure), 'manage_themes|a...')",
            "#23 E:\\wwwroot\\object\\app\\Http\\Middleware\\CheckStoreAdminStatus.php(45): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#24 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): App\\Http\\Middleware\\CheckStoreAdminStatus->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#25 E:\\wwwroot\\object\\app\\Http\\Middleware\\SwitchLanguage.php(28): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#26 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): App\\Http\\Middleware\\SwitchLanguage->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#27 E:\\wwwroot\\object\\vendor\\dingo\\api\\src\\Http\\Middleware\\Auth.php(55): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#28 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Dingo\\Api\\Http\\Middleware\\Auth->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#29 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\Middleware\\Authenticate.php(43): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#30 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Illuminate\\Auth\\Middleware\\Authenticate->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure), 'api')",
            "#31 E:\\wwwroot\\object\\vendor\\dingo\\api\\src\\Http\\Middleware\\PrepareController.php(45): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#32 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Dingo\\Api\\Http\\Middleware\\PrepareController->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#33 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#34 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(683): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
            "#35 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(658): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Dingo\\Api\\Http\\Request))",
            "#36 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(624): Illuminate\\Routing\\Router->runRoute(Object(Dingo\\Api\\Http\\Request), Object(Illuminate\\Routing\\Route))",
            "#37 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(613): Illuminate\\Routing\\Router->dispatchToRoute(Object(Dingo\\Api\\Http\\Request))",
            "#38 E:\\wwwroot\\object\\vendor\\dingo\\api\\src\\Routing\\Adapter\\Laravel.php(88): Illuminate\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))",
            "#39 E:\\wwwroot\\object\\vendor\\dingo\\api\\src\\Routing\\Router.php(518): Dingo\\Api\\Routing\\Adapter\\Laravel->dispatch(Object(Dingo\\Api\\Http\\Request), 'v1')",
            "#40 E:\\wwwroot\\object\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(126): Dingo\\Api\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))",
            "#41 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(130): Dingo\\Api\\Http\\Middleware\\Request->Dingo\\Api\\Http\\Middleware\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#42 E:\\wwwroot\\object\\app\\Http\\Middleware\\ChangeAppUrlMiddleware.php(23): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#43 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): App\\Http\\Middleware\\ChangeAppUrlMiddleware->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#44 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#45 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#46 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#47 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#48 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#49 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#50 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#51 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#52 E:\\wwwroot\\object\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#53 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Fideloper\\Proxy\\TrustProxies->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#54 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
            "#55 E:\\wwwroot\\object\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(127): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
            "#56 E:\\wwwroot\\object\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(103): Dingo\\Api\\Http\\Middleware\\Request->sendRequestThroughRouter(Object(Dingo\\Api\\Http\\Request))",
            "#57 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(171): Dingo\\Api\\Http\\Middleware\\Request->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
            "#58 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
            "#59 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(145): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
            "#60 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))",
            "#61 E:\\wwwroot\\object\\public\\index.php(57): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))",
            "#62 {main}"
        ]
    }
}


2、在构建生产环境中,执行:composer install –prefer-dist –no-ansi –no-interaction –no-progress –no-scripts –no-dev。 3、在 composer.json 的 require 配置中,添加 “moontoast/math”。执行:composer require moontoast/math。再次执行:composer install –prefer-dist –no-ansi –no-interaction –no-progress –no-scripts –no-dev。不再报错。]]>
https://www.shuijingwanwq.com/2022/10/10/7038/feed/ 0
在 GitLab 的 CI / CD 的 Pipelines 中,Build composer 失败 https://www.shuijingwanwq.com/2022/10/08/7027/ https://www.shuijingwanwq.com/2022/10/08/7027/#respond Sat, 08 Oct 2022 06:42:32 +0000 https://www.shuijingwanwq.com/?p=7027 浏览量: 78 1、在 GitLab 的 CI / CD 的 Pipelines 中,Build composer 失败。如图1
在 GitLab 的 CI / CD 的 Pipelines 中,Build composer 失败

图1



$ php artisan key:generate

In DatabaseServiceProvider.php line 88:
                                   
  Class 'Faker\Factory' not found  
                                   

Cleaning up file based variables
ERROR: Job failed: command terminated with exit code 1


2、在本地环境搜索 Class ‘Faker\Factory’,确定 /vendor/fzaninotto/faker/src/Faker/Factory.php 是存在的。在本地环境执行:php artisan key:generate 成功。如图2
在本地环境搜索 Class 'Faker\Factory',确定 /vendor/fzaninotto/faker/src/Faker/Factory.php 是存在的。在本地环境执行:php artisan key:generate 成功

图2



PS E:\wwwroot\object> php artisan key:generate
Application key set successfully.


3、查看 gitlab-runner 中的日志,if [ ! -x “vendor” ];then echo ‘vendor not exists’; composer self-update 2.1.14; composer install –prefer-dist –no-ansi –no-interaction –no-progress –no-scripts –no-dev; else echo ‘vendor exists’; fi。如图3
查看 gitlab-runner 中的日志

图3



$ if [ ! -x "vendor" ];then echo 'vendor not exists'; composer self-update 2.1.14; composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts --no-dev; else echo 'vendor exists'; fi
vendor not exists
You are already using the latest available Composer version 2.1.14 (stable channel).
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Package operations: 233 installs, 0 updates, 0 removals


4、在本地环境执行 composer install –prefer-dist –no-ansi –no-interaction –no-progress –no-scripts –no-dev,然后再执行 php artisan key:generate。报错:In Application.php line 679: Class ‘Barryvdh\Debugbar\ServiceProvider’ not found。原因应该在于本地环境与线上环境的配置项有差异。


PS E:\wwwroot\object> php artisan key:generate

In Application.php line 679:

  Class 'Barryvdh\Debugbar\ServiceProvider' not found




5、在本地环境执行 composer install –prefer-dist –no-ansi –no-interaction –no-progress –no-scripts,然后再执行 php artisan key:generate。不再报错。由此确认原因在于 –no-dev 的添加导致了流水线失败。–no-dev: 跳过 require-dev 字段中列出的包。在 composer.json 的 require-dev 配置中,存在 “fzaninotto/faker”: “^1.4″。


    "require-dev": {
        "fzaninotto/faker": "^1.4",
    },


6、将 require-dev 配置中的 “fzaninotto/faker”: “^1.4” 移至 require 配置中。不再报错。]]>
https://www.shuijingwanwq.com/2022/10/08/7027/feed/ 0