gpt4 book ai didi

php - PhpStorm IDE 错误后缺少 Symfony/Twig 的模板设置页面

转载 作者:行者123 更新时间:2023-12-01 20:27:15 25 4
gpt4 key购买 nike

我只是尝试为 PhpStorm 配置 Twig 设置,以获得模板文件的自动完成和快速跳转。然而,我似乎输入了错误的路径,导致设置页面终止并生成 fatal error 。

这是 PhpStorm 堆栈跟踪:

java.lang.IllegalArgumentException: Argument for @NotNull parameter 'path' of fr/adrienbrault/idea/symfony2plugin/templating/path/TwigPath.<init> must not be null
at fr.adrienbrault.idea.symfony2plugin.templating.path.TwigPath.$$$reportNull$$$0(TwigPath.java)
at fr.adrienbrault.idea.symfony2plugin.templating.path.TwigPath.<init>(TwigPath.java)
at fr.adrienbrault.idea.symfony2plugin.templating.util.TwigUtil.getTwigNamespaces(TwigUtil.java:1337)
at fr.adrienbrault.idea.symfony2plugin.templating.util.TwigUtil.getTemplateNamesForFile(TwigUtil.java:1242)
at fr.adrienbrault.idea.symfony2plugin.templating.util.TwigUtil.getTemplatesExtendingFile(TwigUtil.java:2180)
at fr.adrienbrault.idea.symfony2plugin.templating.util.TwigUtil.getTemplatesExtendingFile(TwigUtil.java:2168)
at fr.adrienbrault.idea.symfony2plugin.twig.loader.FileImplementsLazyLoader.getFiles(FileImplementsLazyLoader.java:35)
at fr.adrienbrault.idea.symfony2plugin.twig.utils.TwigBlockUtil.hasBlockImplementations(TwigBlockUtil.java:66)
at fr.adrienbrault.idea.symfony2plugin.templating.TwigLineMarkerProvider.attachBlockImplements(TwigLineMarkerProvider.java:197)
at fr.adrienbrault.idea.symfony2plugin.templating.TwigLineMarkerProvider.collectSlowLineMarkers(TwigLineMarkerProvider.java:80)
at com.intellij.codeInsight.daemon.impl.LineMarkersPass.a(LineMarkersPass.java:197)
at com.intellij.codeInsight.daemon.impl.LineMarkersPass.a(LineMarkersPass.java:96)
at com.intellij.codeInsight.daemon.impl.Divider.divideInsideAndOutsideInOneRoot(Divider.java:80)
at com.intellij.codeInsight.daemon.impl.LineMarkersPass.doCollectInformation(LineMarkersPass.java:91)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:69)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.e(PassExecutorService.java:423)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1161)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.d(PassExecutorService.java:416)
at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(PassExecutorService.java:415)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.b(PassExecutorService.java:391)
at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:147)
at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:222)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:389)
at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:161)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

这就是设置页面的样子:

empty settings page

如何重置设置页面?我已经卸载了 Symfony 插件(添加/删除设置页面),但没有效果,重新安装时仍然有空白页面。

最佳答案

这个解决方案对我有用:

  • 在操作系统文件资源管理器中打开项目 .idea 目录
  • 找到 symfony2.xml 文件
  • 将文件重命名为 symfony2_bkup.xml
  • 重新安装插件
  • 重新启动 PHPStorm
  • 允许提示启用自动配置
  • 转到“设置”>“语言和框架”>“PHP”>“Symfony”>“Twig/模板”
  • 现在应该可以正常工作了。
  • 如果您有以前的设置,请将它们从备份 xml 文件复制到生成的新文件中。

更新

经过进一步调试,发现你的xml文件中是否有这样的内容:

<option name="twigNamespaces">
<list>
<twig_namespace custom="true" namespace="MyCompany" namespaceType="ADD_PATH" />
</list>
</option>

然后您需要添加路径属性,如下所示:

<option name="twigNamespaces">
<list>
<twig_namespace custom="true" namespace="MyCompany" namespaceType="ADD_PATH" path="path/to/custom/views" />
</list>
</option>

保存 xml 文件更改后,请务必重新启动 PHPStorm!

关于php - PhpStorm IDE 错误后缺少 Symfony/Twig 的模板设置页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53668136/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com