当尝试注册我的 DummyController 以将其用作 Typo3 插件时,我收到以下错误:
ServiceNotFoundException: You have requested a non-existent service "MyVendorName\Typo3StarterSitepackage\Controller\DummyController"
我尝试按照文档所述执行所有操作,并且还做了一些研究,但巴德无法解决问题。这是我的代码:
我的控制器:
<?php
namespace MyVendorName\Typo3StarterSitepackage\Controller;
use Psr\Http\Message\ResponseInterface;
class DummyController extends ActionController
{
public function dummyListAction(): ResponseInterface
{
return $this->htmlResponse();
}
}
我的DummyRepository.php:
<?php
namespace MyVendorName\Typo3StarterSitepackage\Domain\Repository;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
class DummyRepository extends Repository
{
// this already has some default functions, like findAll(), inherited from the Repository class.
}
我的 Services.yaml 文件:
services:
# general settings
_defaults:
autowire: true
autoconfigure: true
public: false
MyVendorName\Typo3StarterSitepackage\:
resource: '../Classes/*'
我的ext_localconf.php:
<?php
use MyVendorName\Typo3StarterSitepackage\Controller\DummyController;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
defined('TYPO3') or die('Access denied.');
/***************
* Add default RTE configuration
*/
// $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['typo3_starter_sitepackage'] = 'EXT:typo3_starter_sitepackage/Configuration/RTE/Default.yaml';
/***************
* PageTS
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:typo3_starter_sitepackage/Configuration/TsConfig/Page/All.tsconfig">');
ExtensionUtility::configurePlugin(
'typo3_starter_sitepackage',
'DummyList',
[DummyController::class => 'dummyList'],
);
使用此代码,我可以通过 Typo3 后端选择插件,但随后会抛出 ServiceNotFoundException。我知道控制器现在没有返回任何内容,但我认为这不是这个问题的原因。
我正在 Windows 上使用 XAMPP 和 PHP 8.2、Typo3 12.4.10。
与这些案例相关的偶然错误是:
并尝试重建缓存
vendor/bin/typo3 cache:flush
vendor/bin/typo3 cache:warump
我终于能够解决这个问题了。我的安装有两个主要问题,老实说,我想部分归咎于 TYPO3 的怪癖和文档不足。无论如何,这是我修复它的方法:
typo3cms install:fixfolderstructure
。这对我来说从来没有用过,因为这条路径对于typo3 12来说似乎是错误的。相反,我设置了typo3 cache:flush
和typo3 cache:warmup
。之后,我删除了composer.lock文件和供应商文件夹,并重新安装了composer包(这可能没有必要)。自动加载后转储脚本现在清除了typo3缓存,运行时没有错误,并且ServiceNotFoundException消失了。