[6.x]: Commerce can't boot without `craftcms/yii2-adapter`

未关闭
#4,402 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@lukeholder 已经在做这个了。

开始于 2026年11月2日。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
php
领域
backend

调研方向

Start by reading HasLegacyBridges::finalizeLegacyRegistrationEvents() and the legacy services in src-yii2/services/OrderAdjustments.php and src-yii2/services/Carts.php; also check how craftcms/yii2-adapter is declared in composer.json. Reproduce on Craft 6 without the adapter and trace what loads during boot. Done means either Commerce boots without the adapter or Composer installs it as a required dependency.

由索引模型根据 Issue 内容生成。

描述

repo:commerce
What happened?

With craftcms/commerce 6.x-dev installed and enabled on a Craft 6 project that doesn't require craftcms/yii2-adapter, every request (site and control panel) fails with Class "yii\base\Component" not found.

HasLegacyBridges::finalizeLegacyRegistrationEvents() registers a booted() callback that always calls LegacyOrderAdjustments::finalizeRegistrationEvents() (and the Gateways / Purchasables equivalents). Those classes live in src-yii2/ and extend yii\base\Component. Guarding that callback with class_exists(\yii\base\Component::class) gets past it, but the legacy craft\commerce\services\Carts service is then loaded on every request and fails the same way.

Is the adapter meant to be a hard requirement of Commerce 6, or should Commerce run without it? It's in require-dev only, so a project gets it only if it requires the adapter itself. If it's required, listing it in require would let Composer install it.

Steps to reproduce
  1. Fresh Craft 6 project (6.x-dev) without craftcms/yii2-adapter.
  2. composer require craftcms/commerce:6.x-dev, then php artisan craft:plugin:install commerce (succeeds).
  3. Load any page.
Expected behavior

Commerce runs, or Composer installs the adapter as a dependency.

Actual behavior

HTTP 500 on every request: Class "yii\base\Component" not found at src-yii2/services/OrderAdjustments.php:16, then src-yii2/services/Carts.php:15.

Craft CMS version

6.x-dev (603f0e0); Commerce 6.x-dev (fa9aedd)

PHP version

8.5

Operating system and version

macOS (Laravel Herd)

Database type and version

MySQL 8

Image driver and version

—

Installed plugins and versions

craftcms/commerce 6.x-dev (plus one private plugin, not involved)

主要语言
PHP
星标
242
派生
172
平均合并
21 小时 23 分钟
30 天内合并 PR
76

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

craftcms/commerce 的其他 Issue

查看 craftcms/commerce 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。