Naseem Toumeh
Naseem Toumeh

Reputation: 13

TYPO3 Extension Development: Composer Autoload Not Recognizing Custom Classes

I'm currently developing a TYPO3 extension and facing an issue with the Composer autoloader not recognizing my custom classes. My goal is to use Extbase to fetch data and pass it to a Fluid template.

MY EXTENSION COMPOSER LOOK IKE THIS

{
  "name": "toumeh/mywebsite",
  "description": "my Website",
  "type": "typo3-cms-extension",
  "license": "GPL-2.0-or-later",
  "authors": [
    {
      "name": "toumeh",
      "email": "[email protected]"
    }
  ],

  "require": {
    "typo3/cms-fluid-styled-content": "^12.4.0",
    "ext-pdo": "*"
  },
  "autoload": {
    "psr-4": {
      "MyWebsite\\Classes\\": "Classes/"
    }
  },
  "extra": {
    "typo3/cms": {
      "extension-key": "mywebsite"
    }
  }
}

Am adding the class to the ext_localconf.php so i can use the Plugin inside of my typoscript setup

use MyWebsite\Classes\Controller\MyWebsiteController;
use MyWebsite\Classes\Domain\PageRepository;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

ExtensionUtility::configurePlugin(
    MyWebsiteController::EXTENSION_NAME,
    MyWebsiteController::PLUGIN_NAME,
    [
        MyWebsiteController::CONTROLLER_NAME => PageRepository::PAGES
    ]
);

am getting the follwoing error

Class "MyWebsite\Classes\Controller\MyWebsiteController" not found

in /var/www/t3coredev/packages/mywebsite/ext_localconf.php line 11 use MyWebsite\Classes\Domain\PageRepository; use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

ExtensionUtility::configurePlugin( MyWebsiteController::EXTENSION_NAME, MyWebsiteController::PLUGIN_NAME, [ MyWebsiteController::CONTROLLER_NAME => PageRepository::PAGES ]

  1. am runing compose dump-autoload but it didn't work
  2. exbase extension is inside of my root composer "typo3/cms-extbase": "^12.4.0"
  3. Am pretty sure it is not permissions problem.

this a snapchat from my project structure enter image description here

am using typo3 composer version 12.4.8

Could someone help me understand why my classes are not being recognized by Composer's autoloader and how I can resolve this issue

Upvotes: 0

Views: 182

Answers (2)

Naseem Toumeh
Naseem Toumeh

Reputation: 13

Thanks to the people who tried to help me. After checking everything, I found that the running composer dump-autoload was not enough to discover the error. After I used composer update, I encountered a permission problem inside of my container

Upvotes: 0

Milenov
Milenov

Reputation: 1

MyWebsite\Classes\Controller\MyWebsiteController - I think this path is your problem. TYPO3 uses some naming conventions, and i'm pretty sure you need to cut the Classes part form that path.

use MyWebsite\Controller\MyWebsiteController; 

Try it out!

Upvotes: 0

Related Questions