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 MyWebsiteClassesControllerMyWebsiteController;
use MyWebsiteClassesDomainPageRepository;
use TYPO3CMSExtbaseUtilityExtensionUtility;
ExtensionUtility::configurePlugin(
MyWebsiteController::EXTENSION_NAME,
MyWebsiteController::PLUGIN_NAME,
[
MyWebsiteController::CONTROLLER_NAME => PageRepository::PAGES
]
);
am getting the follwoing error
Class "MyWebsiteClassesControllerMyWebsiteController" not found
in /var/www/t3coredev/packages/mywebsite/ext_localconf.php line 11
use MyWebsiteClassesDomainPageRepository;
use TYPO3CMSExtbaseUtilityExtensionUtility;ExtensionUtility::configurePlugin(
MyWebsiteController::EXTENSION_NAME,
MyWebsiteController::PLUGIN_NAME,
[
MyWebsiteController::CONTROLLER_NAME => PageRepository::PAGES
]
- am runing compose dump-autoload but it didn’t work
- exbase extension is inside of my root composer "typo3/cms-extbase": "^12.4.0"
- 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
2
Answers
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
MyWebsiteClassesControllerMyWebsiteController
– 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.Try it out!