如何将Typo3 Typoscript常数文件转换为数组或JSON格式



以下是我的Typo3 Typoscript常数文件,我想使用PHP将此文件转换为数组格式。(我使用Laravel 5.5框架)。

这是我的常数。TS文件:

settings {
  social {
    # cat=jay: advanced/120/100; type=integer; label=Facebook page
    facebook = http://www.facebook.com
    # cat=jay: advanced/120/110; type=integer; label=Twitter account
    twitter = https://twitter.com
    # cat=jay: advanced/120/120; type=integer; label=Google Plus Account
    google = https://plus.google.com
    # cat=jay: advanced/120/130; type=integer; label=Direct Mail
    mail = jay@gmail.com
  }
  # cat=jay: advanced/120/140; type=string; label=Path to logo file
  logo = 
}

我在做什么:
我使用

读取此文件
$jsonString = file_get_contents(storage_path() . "/jay/Configuration/TypoScript/Constants/Settings.ts");

那么如何将此文件转换为正确的数组或JSON格式?

您可能会从核心函数中解析它。在API中查看:

typo3/cms/core/typoscript/parser/typoscriptparser :: parse()

https://api.typo3.org/typo3cms/8/html/_typo_script_parser_8php_source.html#l00230

最新更新