定制 cpsit/typo3-config-loader 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cpsit/typo3-config-loader

Composer 安装命令:

composer require cpsit/typo3-config-loader

包简介

A loader for various TYPO3-related configuration, including system configuration and configuration for third-party extensions.

README 文档

README

TYPO3 config loader

Coverage CGL Tests TYPO3 support

📦 Packagist | 💾 Repository | 🐛 Issue tracker

A loader for various TYPO3-related configuration, including system configuration and configuration for third-party extensions. Based on the helhum/config-loader library.

🚀 Features

🔥 Installation

Packagist Packagist Downloads

composer require cpsit/typo3-config-loader

⚡ Usage

Tip

Read more about loader-specific configuration in the appropriate class documentation.

Basic (non-cached)

Add the following code snippet to your project's config/system/additional.php file:

$systemConfigLoader = new CPSIT\Typo3ConfigLoader\Loader\SystemConfigurationLoader();
$systemConfigLoader->load();

In case your project uses EXT:solr, you can load its configuration as well:

$solrConfigLoader = new CPSIT\Typo3ConfigLoader\Loader\SolrConfigurationLoader();
$solrConfigLoader->load();

Cached

You can also use a cached version of the appropriate loaders:

$systemConfigLoader = new CPSIT\Typo3ConfigLoader\Loader\SystemConfigurationLoader();
$systemConfigLoader->loadCached();

🔍 System configuration readers

1. Context specific reader

The Helhum\ConfigLoader\Reader\PhpFileReader receives lowest priority when loading system configuration. It resolves system configuration from a context-specific file path within the app/config/environment directory. The default directory path can be overwritten with an environment variable CONTEXT_CONFIGURATION_PATH. Each file must return an array with additional system configuration values.

Example (default path)

  • TYPO3 context: Development/Local
  • File path: app/config/environment/Development/Local.php

File contents:

# /var/www/html/app/config/environment/Development/Local.php

return [
    'SYS' => [
        'debug' => 1,
    ],
];

Example (custom path)

  • TYPO3 context: Development/Local
  • Environment variable: CONTEXT_CONFIGURATION_PATH=config/by-context
  • File path: config/by-context/Development/Local.php

File contents:

# /var/www/html/config/by-context/Development/Local.php

return [
    'SYS' => [
        'debug' => 1,
    ],
];

2. Environment file reader

The next reader in the priority chain for system configuration is the Helhum\ConfigLoader\Reader\YamlFileReader. It reads additional configuration from a configured YAML file. The file path must be specified as environment variable ENV_FILE_PATH. If the variable is not present, this reader is skipped.

Example

  • Environment variable: ENV_FILE_PATH=/var/www/html/env.yml
  • File path: /var/www/html/env.yml

File:

# /var/www/html/env.yml

SYS:
  debug: 1

3. Environment variables reader

The Helhum\ConfigLoader\Reader\EnvironmentReader receives highest priority. It is used to map environment variables to configuration values. Environment variables must be prefixed by TYPO3 and each configuration key must be separated by __ (two underscore characters).

Example

  • Environment variable: TYPO3__MAIL__transport_smtp_server
  • Configuration path: $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_server']

💡 Custom loaders

In case this library does not fulfill all your requirements, you are free to extend it by your needs. A ConfigurationLoader interface exists which can be used to provide additional loaders. Additionally, you are free to make use of the EnvironmentCreator trait which allows the transformation of loaded configuration to environment variables.

Next to the ConfigurationLoader there exists an extended interface that is able to cache and load cached data. Use CacheableConfigurationLoader and implement the additional method loadCached to make use of cached configuration.

Consider contributing to this project if you feel like some functionality is missing or not yet fully covered.

🚧 Migration

0.4.x/0.5.x → 1.x

  • Removal of environment variables reader compatibility layer
    • Default key separator was changed from _ (one underscore) to __ (two underscores).
    • Support for feature flag environment variable TYPO3_CONFIG_LOADER_USE_SAFE_SEPARATOR was removed.
    • Make sure to convert existing environment variables to make use of the changed key separator, e.g. TYPO3_SYS_debugTYPO3__SYS__debug.
  • Renaming of shipped configuration loader class names
    • Both shipped configuration loaders were renamed from <Type> to <Type>ConfigurationLoader, e.g. SystemSystemConfigurationLoader.
    • Change references to the renamed classes and make sure to adapt the class names as described.
  • Hardening of configuration loader classes
    • Both shipped configuration loaders are now marked as final readonly.
    • Custom configuration loaders may no longer extended default configuration loaders.
    • Change your custom implementations to a direct implementation of the ConfigurationLoader or CacheableConfigurationLoader interfaces.

🧑‍💻 Contributing

Please have a look at CONTRIBUTING.md.

⭐ License

This project is licensed under GNU General Public License 2.0 (or later).

cpsit/typo3-config-loader 适用场景与选型建议

cpsit/typo3-config-loader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.13k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2025 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 cpsit/typo3-config-loader 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cpsit/typo3-config-loader 我们能提供哪些服务?
定制开发 / 二次开发

基于 cpsit/typo3-config-loader 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 12.13k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 6
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2025-04-24