You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何克隆TYPO3扩展?基于现有扩展构建自定义扩展的操作指引

如何克隆TYPO3扩展并创建自有自定义扩展

Hey there! Cloning a TYPO3 extension to build your own custom version is a super common workflow, and I’ll walk you through every step you need to follow, plus all the critical files and parameters you must modify to avoid conflicts and make it your own.


第一步:准备与克隆原扩展

  • First, grab the source code of the extension you want to clone. You can either:
    • Use git clone to pull the repo directly into your TYPO3 project’s typo3conf/ext/ directory
    • Download a ZIP of the extension and extract it into typo3conf/ext/
  • Immediately rename the extension directory to your custom name (follow TYPO3 rules: lowercase letters only, underscores allowed, no special characters). For example, if cloning news, rename it to my_custom_news.

第二步:核心文件与参数修改

These are the non-negotiable changes you need to make to ensure your extension is recognized as a separate, unique extension by TYPO3.

1. Extension Configuration File (ext_emconf.php)

This is TYPO3’s primary way to identify your extension—don’t skip any of these:

  • Update $EM_CONF[$_EXTKEY]['title']: Set your custom extension name (e.g., My Custom News Plugin)
  • Modify $EM_CONF[$_EXTKEY]['description']: Write a clear description explaining this is your customized fork
  • Update $EM_CONF[$_EXTKEY]['author'], $EM_CONF[$_EXTKEY]['author_email'], and $EM_CONF[$_EXTKEY]['author_company'] with your own details
  • Reset $EM_CONF[$_EXTKEY]['version'] to 1.0.0 (or your preferred starting version) to avoid version conflicts with the original extension
  • Verify $EM_CONF[$_EXTKEY]['constraints']['depends']: Keep the TYPO3 version and other dependency requirements aligned with your project needs (you can adjust these later if needed)

2. Composer Configuration (composer.json)

If the original extension uses Composer (most modern ones do), update these fields:

  • name: Change to your own vendor/extension-key format (e.g., yourcompany/my-custom-news)
  • description: Match what you wrote in ext_emconf.php
  • authors: Replace with your team/author information
  • extra.typo3/cms.extension-key: Set this to your new extension directory name (e.g., my_custom_news)
  • Remove any dependencies on the original extension (since you’re now using your own fork)

3. Namespace Replacements (All PHP & Template Files)

TYPO3 uses PSR-4 namespaces, so you’ll need to do a global replace across all files:

  • Find the original extension’s namespace (e.g., Vendor\News) and replace it with your custom namespace (e.g., YourCompany\MyCustomNews)
  • Don’t forget:
    • Fluid templates with custom view helpers (update the namespace declarations in .html files)
    • Configuration files in Configuration/TCA/ or Configuration/Services.yaml that reference the original namespace

If the extension uses custom database tables:

  • Rename tables in ext_tables.sql: Change prefixes like tx_news_domain_model_* to tx_mycustomnews_domain_model_*
  • Rename TCA configuration files in Configuration/TCA/: For example, tx_news_domain_model_news.php becomes tx_mycustomnews_domain_model_news.php, and update all table/namespace references inside
  • Update table registrations in ext_tables.php to match your new table names

5. Plugin/Backend Module Registrations

  • Frontend Plugins: In Configuration/TCA/Overrides/sys_template.php, replace all references to the original extension key (e.g., tx_news) with your new key. Also update the plugin name and description.
  • Backend Modules: In Configuration/Backend/Modules.php, adjust the module identifier, namespace, and labels to match your extension.
  • ext_localconf.php: Update the configurePlugin() call from \TYPO3\CMS\Extbase\Utility\ExtensionUtility:
    \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
        'MyCustomNews', // Your new extension key
        'List', // Plugin name
        [
            \YourCompany\MyCustomNews\Controller\NewsController::class => 'list, show'
        ],
        // non-cacheable actions
        [
            \YourCompany\MyCustomNews\Controller\NewsController::class => ''
        ]
    );
    

6. Language Files

  • Update all language file references in templates and configuration: Replace LLL:EXT:news/Resources/Private/Language/... with LLL:EXT:my_custom_news/Resources/Private/Language/...
  • You can also modify the language strings themselves in Resources/Private/Language/locallang.xlf to fit your custom needs.

第三步: Test & Validate

  • Go to the TYPO3 backend’s Extension Manager, find your new extension, and install it
  • Test all core functionality: frontend plugin rendering, backend CRUD operations, database interactions, etc.
  • If you run into errors, double-check for missed namespace replacements, table name references, or extension key typos—these are the most common pitfalls!

内容的提问来源于stack exchange,提问作者Karine Lévis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:36:03