Search code examples
typo3-9.xtypo3-extensions

Typo3 Extension: Injection of repository doesn't work anyway


I followed the official Guide from Typo3 for creating a new extension (https://docs.typo3.org/m/typo3/book-extbasefluid/9.5/en-us/4-FirstExtension/Index.html). But when I finished, the page with the plugin gives me only an ERROR 500. No Error-Log anyway.

When I enabled ErrorDisplay I found, that there was a problem with boolean values. So I deleted them and tried again. Again all I got was ERROR 500. ErrorDisplay said the constructor cannot have a return value - hu?? Found inline 7 - but the declaration is in line 22 -??

public function __construct(int $j = 0, int $n = 0, int $i = 0, int $p = 0, int $y = 0, int $a = 0): void {...} 

So I tried to delete the return value. But then it told me, that the class couldn't be found. Next, I tried to find anything about that error but found even less than nothing.

I wasn't even able to find extensions that are implementing the way explained by the official guide. Is there anybody who can tell me, what is going wrong and where I can find a solution - I have no idea anymore.


Solution

  • After hours and hours trial and error I found the solution. The Problem is, that Typo3 doesn't give a proper error message due to failing with the exception handling. You have to enable normal PHP Errors to get a clue what is wrong. If there is any php error, Typo3 fails and gives an reflection error, because it thinks the class isn't available.

    First Error was: following the official guide instructions for first extension. Compiler ist failing if you try to give the constructor a return value.

    Second Error: Typo3 doesn't recognize if a parameter in constructor is missing. It tries to take the next parameter and fails by comparing the parameters type.

    Third Error: If the class is missing the instructions for underlying symphony framework the reflection also fails with registering the class without giving any error message.

    After I found and corrected all the errors, all worked fine.