5

I have created an extension for Typo3 4.7 (actually, it was created for Typo3 6.2, but I am trying to backport it) using the extbase framework. I have already removed all namespaces from the core and also checked TYPO3 - Call another repository. However, I have the problem that calling the frontend plugin causes a PHP error PHP Fatal error: Cannot redeclare class [...]\\ProjectController in [...]/ProjectController.php on line 127 (line 127 is the closing brace of the class). Within my plugin, I do not have any require/include except for the "dynamicConfigFile"s.

The controller in question uses dependency injection like this:

/**
 * projectRepository
 *
 * @var Tx_MyExtension_Domain_Repository_ProjectRepository
 * @inject
 */
protected $projectRepository = NULL;

/**
 * sfbRepository 
 *
 * @var Tx_myExtension_Domain_Repository_SFBRepository
 * @inject
 */
protected $sfbRepository = NULL;

and I am running PHP 5.5.14. The whole code works on Typo3 6 if I change the "Tx_..." stuff to use namespaces instead.

So far, I found only one website about this issue (https://forum.typo3.org/index.php/t/203725/), which says that using dependency injection instead of t3lib_div::makeInstance has fixed it. However, I am already using dependency injection.

Furthermore, if I add print_r(get_declared_classes()); before the declaration of the class, it does not print the class in question, i.e. it seems not to be declared.

Has anyone encountered such a problem before? What else could I do to troubleshoot this?

Edit: The whole stack trace is

[Mon Apr 27 17:17:17 2015] [error] [client ] PHP Stack trace:
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP   1. {main}() /srv/www/typo3_src-4.7.11/index.php:0
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP   2. require() /srv/www/typo3_src-4.7.11/index.php:76
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP   3. include() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/index_ts.php:353
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP   4. TSpagegen::renderContent() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/pagegen.php:74
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP   5. tslib_cObj->cObjGet() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_pagegen.php:259
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP   6. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:562
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP   7. tslib_content_User->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP   8. tslib_cObj->callUserFunction() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_user.php:55
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP   9. call_user_func_array:{/srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584}() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  10. tx_templavoila_pi1->main_page() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  11. tx_templavoila_pi1->renderElement() /srv/www/html/typo3conf/ext/templavoila/pi1/class.tx_templavoila_pi1.php:196
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  12. tx_templavoila_pi1->processDataValues() /srv/www/html/typo3conf/ext/templavoila/pi1/class.tx_templavoila_pi1.php:331
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  13. tslib_cObj->cObjGet() /srv/www/html/typo3conf/ext/templavoila/pi1/class.tx_templavoila_pi1.php:605
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  14. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:562
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  15. tslib_content_Records->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  16. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_records.php:124
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  17. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:600
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  18. tslib_content_Case->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  19. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_case.php:52
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  20. tslib_content_ContentObjectArray->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  21. tslib_cObj->cObjGet() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_contentobjectarray.php:48
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  22. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:562
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  23. tslib_content_Case->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  24. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_case.php:52
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  25. tslib_content_User->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  26. tslib_cObj->callUserFunction() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_user.php:55
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  27. call_user_func_array:{/srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584}() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  28. Tx_Extbase_Core_Bootstrap->run() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  29. Tx_Extbase_Core_Bootstrap->handleWebRequest() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Core/Bootstrap.php:212
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  30. Tx_Extbase_MVC_Web_FrontendRequestHandler->handleRequest() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Core/Bootstrap.php:242
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  31. Tx_Extbase_MVC_Dispatcher->dispatch() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/MVC/Web/FrontendRequestHandler.php:85
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  32. Tx_Extbase_MVC_Dispatcher->resolveController() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/MVC/Dispatcher.php:94
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  33. Tx_Extbase_Object_ObjectManager->get() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/MVC/Dispatcher.php:114
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  34. Tx_Extbase_Object_Container_Container->getInstance() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Object/ObjectManager.php:109
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  35. Tx_Extbase_Object_Container_Container->getInstanceInternal() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Object/Container/Container.php:120
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  36. Tx_Extbase_Object_Container_Container->getClassInfo() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Object/Container/Container.php:159
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  37. Tx_Extbase_Object_Container_ClassInfoFactory->buildClassInfoFromClassName() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Object/Container/Container.php:345
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  38. ReflectionClass->__construct() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Object/Container/ClassInfoFactory.php:43
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  39. spl_autoload_call() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Object/Container/ClassInfoFactory.php:43
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  40. t3lib_autoloader::autoload() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Object/Container/ClassInfoFactory.php:43
[Mon Apr 27 17:17:17 2015] [error] [client ] PHP  41. t3lib_div::requireFile() /srv/www/typo3_src-4.7.11/t3lib/class.t3lib_autoloader.php:97

Edit: In the meantime, I have tried using namespaces and removing them - the result is the same in either case. Furthermore, removing the dependency injection has no effect either. If I add a !class_exists() check around the declaration, the script does not crash, but an exception is raised and Typo3 complains about the class being not defined in the log. It is almost as if the class were somehow there, but cannot be used or is somehow different ...

Edit: I have now renamed (hopefully) all classes and comments to match the extbase naming scheme. However, the error moved and the call stack is now like:

[Tue Apr 28 15:33:52 2015] [error] [client ] PHP Fatal error:  Cannot redeclare class Tx_MyExtension_Model_Domain_Project in /srv/www/html/typo3conf/ext/my_extension/Classes/Domain/Model/Project.php on line 383
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP Stack trace:
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP   1. {main}() /srv/www/typo3_src-4.7.11/index.php:0
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP   2. require() /srv/www/typo3_src-4.7.11/index.php:76
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP   3. include() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/index_ts.php:353
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP   4. TSpagegen::renderContent() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/pagegen.php:74
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP   5. tslib_cObj->cObjGet() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_pagegen.php:259
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP   6. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:562
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP   7. tslib_content_User->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP   8. tslib_cObj->callUserFunction() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_user.php:55
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP   9. call_user_func_array:{/srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584}() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  10. tx_templavoila_pi1->main_page() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  11. tx_templavoila_pi1->renderElement() /srv/www/html/typo3conf/ext/templavoila/pi1/class.tx_templavoila_pi1.php:196
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  12. tx_templavoila_pi1->processDataValues() /srv/www/html/typo3conf/ext/templavoila/pi1/class.tx_templavoila_pi1.php:331
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  13. tslib_cObj->cObjGet() /srv/www/html/typo3conf/ext/templavoila/pi1/class.tx_templavoila_pi1.php:605
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  14. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:562
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  15. tslib_content_Records->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  16. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_records.php:124
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  17. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:600
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  18. tslib_content_Case->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  19. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_case.php:52
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  20. tslib_content_ContentObjectArray->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  21. tslib_cObj->cObjGet() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_contentobjectarray.php:48
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  22. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:562
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  23. tslib_content_Case->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  24. tslib_cObj->cObjGetSingle() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_case.php:52
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  25. tslib_content_User->render() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:615
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  26. tslib_cObj->callUserFunction() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/content/class.tslib_content_user.php:55
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  27. call_user_func_array:{/srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584}() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  28. Tx_Extbase_Core_Bootstrap->run() /srv/www/typo3_src-4.7.11/typo3/sysext/cms/tslib/class.tslib_content.php:6584
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  29. Tx_Extbase_Core_Bootstrap->handleWebRequest() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Core/Bootstrap.php:212
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  30. Tx_Extbase_MVC_Web_FrontendRequestHandler->handleRequest() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Core/Bootstrap.php:242
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  31. Tx_Extbase_MVC_Dispatcher->dispatch() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/MVC/Web/FrontendRequestHandler.php:85
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  32. Tx_Extbase_MVC_Controller_ActionController->processRequest() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/MVC/Dispatcher.php:96
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  33. Tx_Extbase_MVC_Controller_ActionController->callActionMethod() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/MVC/Controller/ActionController.php:166
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  34. call_user_func_array:{/srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/MVC/Controller/ActionController.php:305}() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/MVC/Controller/ActionController.php:305
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  35. Tx_MyExtension_Controller_ProjectController->listAction() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/MVC/Controller/ActionController.php:305
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  36. Tx_Extbase_Persistence_Repository->findByUid() /srv/www/html/typo3conf/ext/my_extension/Classes/Controller/ProjectController.php:90
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  37. Tx_Extbase_Persistence_Query->equals() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Persistence/Repository.php:339
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  38. Tx_Extbase_Persistence_Query->getSelectorName() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Persistence/Query.php:454
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  39. Tx_Extbase_Persistence_Query->getSource() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Persistence/Query.php:196
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  40. Tx_Extbase_Persistence_Mapper_DataMapper->convertClassNameToTableName() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Persistence/Query.php:210
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  41. Tx_Extbase_Persistence_Mapper_DataMapper->getDataMap() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Persistence/Mapper/DataMapper.php:558
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  42. Tx_Extbase_Persistence_Mapper_DataMapFactory->buildDataMap() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Persistence/Mapper/DataMapper.php:545
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  43. Tx_Extbase_Reflection_Service->getClassSchema() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Persistence/Mapper/DataMapFactory.php:136
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  44. Tx_Extbase_Reflection_Service->buildClassSchema() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Reflection/Service.php:236
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  45. Tx_Extbase_Reflection_Service->getClassPropertyNames() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Reflection/Service.php:424
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  46. Tx_Extbase_Reflection_Service->reflectClass() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Reflection/Service.php:220
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  47. Tx_Extbase_Reflection_Service->convertParameterReflectionToArray() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Reflection/Service.php:393
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  48. Tx_Extbase_Reflection_ParameterReflection->getClass() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Reflection/Service.php:456
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  49. ReflectionParameter->getClass() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Reflection/ParameterReflection.php:61
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  50. spl_autoload_call() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Reflection/ParameterReflection.php:61
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  51. t3lib_autoloader::autoload() /srv/www/typo3_src-4.7.11/typo3/sysext/extbase/Classes/Reflection/ParameterReflection.php:61
[Tue Apr 28 15:33:52 2015] [error] [client ] PHP  52. t3lib_div::requireFile() /srv/www/typo3_src-4.7.11/t3lib/class.t3lib_autoloader.php:97

When looking at the callstack, I wonder wheher the "inheritance problem" of spl_autoload_call described at http://php.net/manual/de/function.spl-autoload-call.php could be related to the issue.

Another update: Now that my own code is in the call stack, I was able to find the root cause of the issue. I can now comment out a call to a second repository ($this->sfbRepository->findByUid($id);) and the plugin is working. The import looks like:

/**
 * sfbRepository 
 *
 * @var Tx_MyExtension_Domain_Repository_SFBRepository
 * @inject
 */
protected $sfbRepository = NULL;

The declaration of the repository is:

class Tx_MyExtension_Domain_Repository_SFBRepository extends \Tx_Extbase_Persistence_Repository {
}

Final Update: The last one just was a typo in the (changed) class name ...

Community
  • 1
  • 1
Christoph
  • 1,964
  • 2
  • 27
  • 44
  • you could try checking with [class_exists()](http://php.net/manual/en/function.class-exists.php) on the line before declaring your class just to be certain what PHP thinks is going on at that point. – totallyNotLizards Apr 27 '15 at 15:27
  • One fact to take in count is that extbase and flow/fluid have are not at the same version in TYPO3 4.7 and TYPO3 6.2. – David Ansermot Apr 27 '15 at 15:31
  • @jammypeach: I have tried this. Now it says "Oops, an error occurred!" on the Website and no error in the server log. The Typo3 log says that it could not find the class (Uncaught TYPO3 Exception: #1289386765) – Christoph Apr 27 '15 at 15:34
  • @David'mArm'Ansermot: What would be the implication of that, ie what would I need to change? – Christoph Apr 27 '15 at 15:35
  • 1
    replace all require to require_once, include to include_once globaly, because autoloader rises this error in 't3lib/class.t3lib_autoloader.php:97' – jskidie Apr 27 '15 at 16:27
  • It would be interesting to see line 127 of your ProjectController.php if the error is triggered there :-). – lorenz Apr 27 '15 at 16:50
  • BTW, no include_once or require_once necessary if the extension uses the proper Extbase structure. – lorenz Apr 27 '15 at 19:46
  • @lorenz: Line 127 is the closing brace of the class ... – Christoph Apr 28 '15 at 08:44
  • @lorenz: If I remove the namespaces, am I required to adapt my naming scheme to be extbase-compliant? In other words: should I rename the class to Tx_MyExtension_Controller_ProjectController? – Christoph Apr 28 '15 at 08:51
  • I added this as a preliminarly answer I will extend until the problem is solved. – lorenz Apr 28 '15 at 08:57

1 Answers1

1

In order to have no hassle with autoloading, you need to stick to the Extbase naming convention even if you're not using namespaces:

Tx_MyExtension_Controller_ProjectController

should be the following file:

EXT:my_extension/Classes/Controller/ProjectController.php

(Mind the UpperCamelCase extension name which transform to underscores in the directory structure.)

If you don't know which 6.2 class was which class in TYPO3 4.x, you can search for them in the "Legacy Classes for IDE" file. Keep in mind to also adapt @inject annotations because the injection is based on the annotation:

* @var Tx_MyExtension_Domain_Repository_ProjectRepository
* @inject
lorenz
  • 4,538
  • 1
  • 27
  • 45
  • I believe, I am on the right track. Removing namespaces and renaming classes moves the error ... The problem is that the Extension was created by the 6.0 wizard, so there is a lot of new stuff. What should I do about the "templates" like `\TYPO3\CMS\Extbase\Persistence\ObjectStorage<[...]\Domain\Model\Project>`? – Christoph Apr 28 '15 at 09:35
  • I (hopefully) have updated all stuff in the model, persistency, controller, but now I have the very same effect with the `Project` class from the domain model - so the naming has definitely something to do with it. Is it necessary to update the comments, too? – Christoph Apr 28 '15 at 10:01
  • The `@injects` are all updated, but I did not update the other `@var`s and `@return`s. Are the `@inject`s sufficient? – Christoph Apr 28 '15 at 10:09
  • I think (but I'm not sure) that the `@var`s should be updated to because they are used for property mapping. But please test it. – lorenz Apr 28 '15 at 11:39
  • The `@var`s are probably to required as the behaviour did not change. However, removing all namespaces in the code and the `@inject`s seems definitely to be required. – Christoph Apr 28 '15 at 14:05
  • Yes, this is definitely required as Extbase does a reflection on the properties and determines which classes to inject based on the reflection. – lorenz Apr 28 '15 at 14:08
  • My last addition was wrong, the issue is not caused by calling a method on the `ProjectRepository`, but when calling another repository I have injected. I use the built-in `findByUid` method. When exactly does Typo3 satisfy the `@inject` - when the containing class is instantiated or if it is used for the same time? – Christoph Apr 28 '15 at 14:13
  • A final addition: *all* `@var`s need to be updated. If they are not, the script will not crash (no HTTP 505), but it will throw an exception and the log says that the class was not found. – Christoph Apr 28 '15 at 14:42