0

I have created an extension with plugins in a vendor namespace. Everything works fine so far. All the classes start with a namespace declaration namespace \VENDOR\ExtensionName\... and typo3 autoloads them just fine.

However, the problem starts when I add a ViewHelper. I put this in the \VENDOR\ExtensionName\ViewHelpers namespace. I added the namespace in my Fluid template like so: {namespace ns=VENDOR\ExtensionName\ViewHelpers}. When I call it in the template with <ns:myViewHelper />, I just get an 'Oops ...' error message:

Could not analyse class:VENDOR\ExtensionName\ViewHelpers\MyViewHelperViewHelper maybe not loaded or no autoloader?

The same happens, when I put the ViewHelper in a \TYPO3\... namespace.

How do I correctly implement a ViewHelper in an extension with a vendor namespace?

1 Answer 1

3

The namespace declaration must not have a leading backslash.

Instead having \Vendor\ExtensionName\ViewHelpers; it has to be Vendor\ExtensionName\ViewHelpers;

http://www.php.net/manual/en/language.namespaces.nested.php

Sign up to request clarification or add additional context in comments.

1 Comment

If this helped you, please mark it as solved. Otherwise let me know what not worked or if you found another solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.