You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Shopware 6插件激活报错:找不到SwagOktaSSO\Controller\AuthController类

Shopware 6插件激活报错:找不到AuthController类的解决方法

开发Shopware 6自定义插件SwagOktaSSO,上传安装后激活时出现内部服务器错误:

Internal Server Error
Class "SwagOktaSSO\Controller\AuthController" used for service 
"SwagOktaSSO\Controller\AuthController" cannot be found.

仅拥有后台管理权限,无服务器访问权限。

问题根源

核心是命名空间不匹配:插件主类的命名空间与自动加载规则、控制器命名空间不一致,导致PHP无法找到对应类文件。

修复步骤

1. 修正插件主类的命名空间

修改src/SwagOktaSSO.php的命名空间,将Swag\OktaSSO改为SwagOktaSSO:

<?php declare(strict_types=1);

namespace SwagOktaSSO;

use Shopware\Core\Framework\Plugin;

class SwagOktaSSO extends Plugin
{
}   

2. 同步composer.json的插件类路径

修改composer.json中extra字段的shopware-plugin-class,匹配新的命名空间:

"extra": {
  "shopware-plugin-class": "SwagOktaSSO\\SwagOktaSSO",
  // 其余字段保持不变
}

3. 验证plugin.xml的类配置

检查plugin.xml中的pluginClass属性,确保与主类命名空间一致:

<plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/platform/trunk/src/Core/Framework/Plugin/Resources/plugin.xsd">
  <name>SwagOktaSSO</name>
  <version>1.0.0</version>
  <pluginClass>SwagOktaSSO\SwagOktaSSO</pluginClass>
  <!-- 其余配置保持不变 -->
</plugin>

4. 处理Auth0依赖(可选但必要)

由于控制器中引入了Auth0\SDK\Auth0,需在composer.json的require中添加依赖:

"require": {
  "shopware/core": "~6.6.0",
  "auth0/auth0-php": "^8.0"
}

5. 重新打包上传

将修改后的所有文件重新打包为Zip(确保根目录为SwagOktaSSO/),通过后台重新上传、安装并激活插件。

内容的提问来源于stack exchange,提问作者padha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 15:07:05