pagemachine/typo3-formlog 问题修复 & 功能扩展

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

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

pagemachine/typo3-formlog

Composer 安装命令:

composer require pagemachine/typo3-formlog

包简介

Form log for TYPO3

README 文档

README

Form log for TYPO3

Installation

  1. Via Composer:

    composer require pagemachine/typo3-formlog

    From the TYPO3 Extension Repository

  2. Add the Site Set pagemachine/formlog as dependency to your site configuration:

    dependencies:
      - pagemachine/formlog

    Alternatively add the "Form Log" static TypoScript template or import the TypoScript setup:

    @import 'EXT:formlog/Configuration/TypoScript/setup.typoscript'
    

Purpose

One feature absent in the TYPO3 form extension is logging of form data. If you have ever used the now defunct Formhandler extension you know how valuable this can be. You can easily check if form submissions are working as they should, see internal values are generated correctly and perform some basic analysis thanks to exports to CSV or similar.

See our blog post about the TYPO3 form log extension.

Start logging

Logging can be enabled for any form by adding the LogFormData finisher to its form definition:

finishers:
  - ...

  - identifier: LogFormData

  - identifier: Redirect

The LogFormData finisher should be the last finisher or right before the Redirect finisher if used. Logging after a redirect is not possible.

Additional variables stored in the FinisherVariableProvider can also be logged by using the finisherVariables option:

  - identifier: LogFormData
    options:
      finisherVariables:
        MyCustomFinisher:
          - myCustomVariable

The keys within finisherVariables are identifiers of finishers used in a form, the value of each entry is a list of finisher variable names. In the example here the finisher variable myCustomVariable provided by the finisher MyCustomFinisher will be logged.

Form log module

By default the form log module displays a few basic fields like page, form identifier, language and date of form submission as columns.

Additional columns can be added with the list.columns setting in TypoScript loaded via ext_localconf.php:

ExtensionManagementUtility::addTypoScriptSetup(<<<TYPOSCRIPT
module.tx_formlog {
  settings {
    list {
      columns {
        100 {
          property = data.email
          label = LLL:EXT:my_site/Resources/Private/Language/Extensions/Form/locallang.xlf:element.email.properties.label
        }
      }
    }
  }
}
TYPOSCRIPT);

Within list.columns an arbitrary list of columns can be added where the property option refers to a property path in the FormLogEntry domain model. Simply speaking data.* provides access to form data by a form element identifier, e.g. data.email for the value of the form element email. The label option is used to retrieve a translatable label. Usually one can simply use the same label that is used for the field within the form itself.

Similarly finisherVariables.* does the same for additional finisher variables by utilizing the finisher identifier and variable name:

ExtensionManagementUtility::addTypoScriptSetup(<<<TYPOSCRIPT
module.tx_formlog {
  settings {
    list {
      columns {
        200 {
          property = finisherVariables.MyCustomFinisher.myCustomVariable
          label = LLL:EXT:my_site/Resources/Private/Language/Extensions/Formlog/locallang.xlf:formlog.entry.finisherVariables.MyCustomFinisher.myCustomVariable
        }
      }
    }
  }
}
TYPOSCRIPT);

Here myCustomVariable of MyCustomFinisher is added as column to the list.

Form log export

Out of the box form log entries can be exported to CSV and Excel (XLSX). Basic fields of form log entries are exported by default, additional columns can be added with the export.columns setting in TypoScript loaded via ext_localconf.php which is configured exactly the same as the list.columns setting:

ExtensionManagementUtility::addTypoScriptSetup(<<<TYPOSCRIPT
module.tx_formlog {
  settings {
    export {
      columns {
        100 {
          property = data.firstname
          label = LLL:EXT:my_site/Resources/Private/Language/Extensions/Form/locallang.xlf:element.firstname.properties.label
        }
        101 {
          property = data.lastname
          label = LLL:EXT:my_site/Resources/Private/Language/Extensions/Form/locallang.xlf:element.lastname.properties.label
        }
        102 {
          property = data.email
          label = LLL:EXT:my_site/Resources/Private/Language/Extensions/Form/locallang.xlf:element.email.properties.label
        }
        200 {
          property = finisherVariables.MyCustomFinisher.myCustomVariable
          label = LLL:EXT:my_site/Resources/Private/Language/Extensions/Formlog/locallang.xlf:formlog.entry.finisherVariables.MyCustomFinisher.myCustomVariable
        }
      }
    }
  }
}
TYPOSCRIPT);

Log entry cleanup

The Table garbage collection Scheduler task can be set up to automatically delete old form log entries. Select tx_formlog_entries as Table to clean up and a suitable value for Delete entries older than given number of days, 180 by default.

Testing

All tests can be executed with the shipped Docker Compose definition:

docker compose run --rm app composer build

Thanks

Development of this package was proudly sponsored by TÜV Hessen.

pagemachine/typo3-formlog 适用场景与选型建议

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

它主要适用于以下技术方向: 「log」 「form」 「typo3」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 236.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 19
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 23
  • Watchers: 6
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2018-02-23