[英]TYPO3 10 Viewhelper class not found, Fluid error
There is some small detail I seem to be missing but I just can't find out what it is...我似乎遗漏了一些小细节,但我就是不知道它是什么......
I get this error:我收到此错误:
Error: The ViewHelper "<ugh:example>" could not be resolved. Based on your spelling, the system would load the class "TYPO3\Projectname\ViewHelpers\ExampleViewHelper", however this class does not exist.
I have my own extension called sitepackage
, which works without issues.我有自己的扩展名为
sitepackage
,它可以正常工作。
In my ext_localconf.php
I wrote在我的
ext_localconf.php
我写
$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['ugh'] = ['TYPO3\\Projectname\\ViewHelpers'];
Then there's the directory ViewHelpers
inside Classes
with the file ExampleViewHelper.php
然后是
Classes
中的目录ViewHelpers
,文件ExampleViewHelper.php
<?php
namespace TYPO3\Projectname\ViewHelpers;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
// etc ...
I expect it to use like <ugh:example />
我希望它像
<ugh:example />
一样使用
What am I missing?我错过了什么? Is there something outside of this that I have to do?
除此之外,我还有什么需要做的吗? I'm freaking out about this...
我吓坏了这...
Your global configuration works, yet PHP is not able to find your TYPO3\Projectname\ViewHelpers\ExampleViewHelper
.您的全局配置有效,但 PHP 无法找到您的
TYPO3\Projectname\ViewHelpers\ExampleViewHelper
。
I suspect that you have a spelling error or your autoloading information is out of date (assuming a composer-based installation, composer dump-autoload
updates it) or you forgot to add your namespace to composer.json
(see composer docs or a TYPO3 extension example here ).我怀疑您有拼写错误或您的自动加载信息已过期(假设基于 composer 的安装,
composer dump-autoload
会更新它)或者您忘记将命名空间添加到composer.json
(请参阅composer 文档或TYPO3 扩展这里的例子)。
That said, the usual approach is to add ViewHelper namespaces to the Fluid template directly.也就是说,通常的方法是直接将 ViewHelper 命名空间添加到 Fluid 模板。 See https://docs.typo3.org/m/typo3/book-extbasefluid/10.4/en-us/8-Fluid/8-developing-a-custom-viewhelper.html#importing-namespaces
请参阅https://docs.typo3.org/m/typo3/book-extbasefluid/10.4/en-us/8-Fluid/8-developing-a-custom-viewhelper.html#importing-namespaces
Without composer没有作曲家
Use TYPO3 InstallTool "rebuild autoload information" or similar to build the class autoloading information.使用 TYPO3 InstallTool“重建自动加载信息”或类似工具来构建 class 自动加载信息。 I think ext_emconf.php needs to contain the autoloading information, too.
我认为 ext_emconf.php 也需要包含自动加载信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.