TYPO3:未捕获错误:找不到任何要使用的类.请始终告诉我此错误



我正在尝试构建一个扩展。在这个扩展中,我试图连接到TYPO3的数据库,但我无法访问这个类,并且任何类总是找不到

use TYPO3CMSCoreDatabaseConnectionPool;
use TYPO3CMSCoreUtilityGeneralUtility;
class rpc {
/**
*
* @var string
*/
public $tsc_Endpoint = '';
/**
*
* @var string
*/
public $tsc_tokenID = '';
/**
* The main method of the backend module
*/
public function main(){
$connection = GeneralUtility::makeInstance(
ConnectionPool::class)
->getConnectionForTable('gpi_configurations');
$queryBuilder = $connection->createQueryBuilder();
$query = $queryBuilder
->select('*')
->from('gpi_configurations')
->where('config_name = tsc_Endpoint');
$rows = $query->execute->fetchRows();
print_r($rows);

$client = GeneralUtility::makeInstance(GpiClient::class);
try {
$server = GeneralUtility::makeInstance(JsonRpc::class)->__construct($client);
} catch (Exception $e) {
}
echo  $server->process();
}

}
$q = new rpc();
$q->main();

我想在一个名为rpc.php 的文件中提到这部分代码

有没有办法访问rpc.php上的TYPO3功能?我做了很多搜索,但没有找到任何有用的帮助。

安装结构

完整编辑:

从我们下面的对话中,我认为您需要一个Middleware来提供一个端点。这个端点从TYPO3数据库读取数据,将您的rpc服务传递给它们,并返回一些JSON作为$response

  • 为了确保自动加载,所有的PHP代码都应该放在Classes/文件夹中
  • 你必须在课堂上使用namespace MazenYourExtensionName...
  • 我建议将您的rpc类作为一个服务,并将其放入Classes/Service/中,但我可能对您的应用程序了解不够
  • 阅读关于TYPO3 Doctrine的文档,尤其是关于WHERE clause的部分
  • 阅读和学习一些关于TYPO3扩展开发的基础知识可能是个好主意

中间件

  • https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/RequestHandling/Index.html
  • 德语,但对于Mailchimp端点来说,这是一个不错的片段:https://various.at/news/typo3-tipps-und-tricks-psr-15-mideelware-am-beispiel-mailchimp-webhook#c971

条令

  • https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Database/QueryBuilder/Index.html#where-以及在何处或何处

服务

服务API本身已被弃用,但您仍然可以将应用程序的某些部分分组到服务中,并使用依赖项注入从任何需要它们的地方加载它们。

  • https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/DependencyInjection/Index.html

TYPO3扩展开发

  • 开发TYPO3扩展:https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/Index.html

相关内容

最新更新