shopwareshopware6

Shopware 6 Plugin Activation Error: Class "SwagOktaSSO\Controller\AuthController" Not Found


I am creating custom plugin for Shopware 6. Below is zip file structure:

└── SwagOktaSSO/
    ├── src/
    │   ├── Controller/
    │   │   ├── AuthController.php
    │   ├── Resources/
    │   │   ├── config/
    │   │   │   ├── services.xml
    │   ├── SwagOktaSSO.php
    ├── composer.json
    ├── plugin.xml

services.xml has below code:

<service id="SwagOktaSSO\Controller\AuthController"
         class="SwagOktaSSO\Controller\AuthController"
         public="true">
    <argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService" />
    <tag name="controller.service_arguments"/>
</service>

composer.json has below code:

{
  "name": "swag/okta-sso",
  "description": "Okta SSO integration for Shopware",
  "version": "1.0.0",
  "type": "shopware-platform-plugin",
  "license": "MIT",
  "authors": [
    {
      "name": "Shopware"
    }
  ],
  "require": {
    "shopware/core": "~6.6.0"
  },
  "autoload": {
    "psr-4": {
      "SwagOktaSSO\\": "src/"
    }
  },
  "extra": {
    "shopware-plugin-class": "SwagOktaSSO\\SwagOktaSSO",
    "label": {
      "de-DE": "SwagOktaSSO",
      "en-GB": "SwagOktaSSO"
    },
    "description": {
      "de-DE": "Beschreibung in der Administration für das Plugin",
      "en-GB": "Description in the Administration for this plugin"
    }
  }
}

AuthController.php:

<?php
namespace SwagOktaSSO\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Auth0\SDK\Auth0;

class AuthController extends AbstractController
{
.....
} 

SwagOktaSSO.php:

<?php declare(strict_types=1);

namespace Swag\OktaSSO;

use Shopware\Core\Framework\Plugin;

class SwagOktaSSO extends Plugin
{
}   

I upload my .zip file from Extension -> My extension -> Upload extension; it successfully uploaded and installed. However, it creates a problem while activating this plugin.

The error is as below:

Internal Server Error

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

How to solve this issue and activate my custom plugin? I only have a myshop/admin login. No server access. Please guide me through.

Thanks in advance!


Solution

  • The configuration is generally okay.

    However, the namespace declared in your main plugin class, SwagOktaSSO.php, does not match the shopware-plugin-class entry in your composer.json file.

    namespace Swag\OktaSSO
    

    "shopware-plugin-class": "SwagOktaSSO\\SwagOktaSSO",

    It likely fails to properly load the rest of the plugin's resources, which is strange, It's unusual for a plugin to be installed with such a mismatch.