b13/typo3-config 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

b13/typo3-config

Composer 安装命令:

composer require b13/typo3-config

包简介

Fluent API to set environment-specific configuration for TYPO3

README 文档

README

TLDR: Don't repeat yourself.

At b13 we run similar code and site-specific functionality based on the actual environment (development / production context). For this, we usually have a list of default "best practice" settings which we usually copy from one project to the next.

This small library ships with a single PHP class which makes our life a bit easier when setting global $TYPO3_CONF_VARS settings, which usually takes place in LocalConfiguration, AdditionalConfiguration and the extensions' ext_localconf.php files.

Note using TYPO3 v12

The configuration files LocalConfiguration and AdditionalConfiguration have been moved and renamed, see Configuration files

Reason 1: We want context-dependent config files

With our configuration class, TYPO3's "AdditionalConfiguration" (located in :file:typo3conf/AdditionalConfiguration.php) just looks like this:

<?php

    \B13\Config::initialize()
        ->appendContextToSiteName()
        ->includeContextDependentConfigurationFiles();

This sets some sensible defaults (see below), and also checks for the existence of the following files:

config/system/development.php
config/system/production.php

If you have a TYPO3_CONTEXT with Subcontexts such as "Production/QA" then the file config/system/production/qa.php is also included, in addition to config/system/production.php.

Reason 2: We don't want to repeat the same "best b13 practice"

The initialize() method sets sensible defaults for a specific environment, activates debugging for Development environments, and deactivates deprecation logging in production by default.

b13 uses DDEV-Local for local environments, however, it is somehow tedious to maintain the same configuration over and over again. If DDEV-Local is in use, initialize automatically sets the respective settings for DDEV-Local environments.

If you want to avoid any kind of magic, you can just use this in your AdditionalConfiguration file.

<?php
    \B13\Config::initialize(false)
        ->appendContextToSiteName()
        ->includeContextDependentConfigurationFiles();

On top, the API ships with useful helper methods which we accustomed to set specific values. You can use this API in combination with setting other environment- or project-specific settings of course.

\B13\Config::get()
    ->useMailhog()
    ->allowInvalidCacheHashQueryParameter()
    ->initializeRedisCaching();

# Also set other TYPO3 configuration values as you need
$GLOBALS['TYPO3_CONF_VARS']['FE']['versionNumberInFilename'] = 'embed';

Installation

Install this package in composer req b13/typo3-config in your existing TYPO3 project – you are ready to go. This package only supports TYPO3 v9 LTS and higher, as we consider having multiple branches for multiple versions at some point where this package provides a stable API while not modifying.

Why we created this package

We use this approach for a few years now and publishing this package helps us to maintain this logic in a standardized way. We invite other web agencies to do the same, to see what everybody can improve and we can collaborate.

TYPO3 does not have a good API to set such options for developers, and this is our list of best practices, which we love to share with the world until TYPO3 Core will provide a standardized and better solution.

With TYPO3 it is possible to configure your system in many ways, and some do this via extensions, and we do it like this, hence: a common ground for us to use.

Drawbacks

  1. If you have a slow file system (NFS) or older PHP version, where your files are located, this package might slow down your file system due to a few more file look ups. Ideally we'd love to cache such information, but TYPO3 Core does not work with cached configuration for TYPO3_CONF_VARS.

  2. Using the "Install Tool" to set global configuration values might not work as expected, as our configuration logic currently works AFTER LocalConfiguration.php has been loaded. This is one of the major issues with TYPO3 Core's configuration system.

Naming TYPO3_CONTEXT

This package works best in TYPO3 projects if you use Git, Composer and various environments. We usually use Contexts also in TYPO3's site configuration and think it is very powerful to use if done right. Internally we committed ourselves across projects to the following names.

Regular projects

  • Development
  • Development/DDEV
  • Testing (CI)
  • Testing/Unit (CI)
  • Production/Live
  • Production/Staging
  • Production/Staging/Feature-TicketNo
  • Production/Staging/Feature-TicketNo2

If you have one code base that powers multiple sites, we use sub-sub-schema as well.

  • Production/Staging/SiteA
  • Production/Staging/SiteB
  • Production/Staging/SiteC
  • Production/Live/SiteA
  • Production/Live/SiteB
  • Production/Live/SiteC

Thanks

Prior functionality was heavily inspired by Neos Flow, and our initial TYPO3 solution was developed by Achim Fritz.

License

The package is licensed under GPL v2+, same as the TYPO3 Core. For details see the LICENSE file in this repository.

Credits

This package was created by Achim Fritz and Benni Mack in 2021 for b13 GmbH.

Find more TYPO3 packages we have developed that help us deliver value in client projects. As part of the way we work, we focus on testing and best practices to ensure long-term performance, reliability, and results in all our code.

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 64.25k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 22
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 7
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2021-11-02