简体   繁体   English

TYPO3 + 作曲家 + 部署

[英]TYPO3 + Composer + Deployment

I thought when migrating projects to composer, one big benefit would be to have a small project repository left where alle the composer managed stuff (TYPO3 sources + public extensions) could be excluded from VCS.我认为在将项目迁移到作曲家时,一个很大的好处是留下一个小的项目存储库,其中所有作曲家管理的东西(TYPO3 源 + 公共扩展)都可以从 VCS 中排除。 On deployment, a „composer install“ on live system would always lead to the desired state without risk.在部署时,实时系统上的“composer install”总是会导致所需的 state 没有风险。

But official TYPO3 documentation says:但是官方TYPO3 文档说:

You should not run composer on your live webspace.您不应该在您的实时网络空间上运行 composer。 You should always run composer on your local or a dedicated deployment machine, so you can test if everything worked fine.您应该始终在本地或专用部署机器上运行 composer,这样您就可以测试一切是否正常。 After running your tests, you can deploy the vendor and public folder to your web server.运行测试后,您可以将供应商和公用文件夹部署到 web 服务器。

I cannot follow why.我无法理解为什么。 Because this leads to each projects repository needs to contain the whole TYPO3 sources in the projects VCS, although they might be excluded there.因为这导致每个项目存储库都需要在项目 VCS 中包含整个 TYPO3 源,尽管它们可能在那里被排除在外。 What are the reasons for this approach and what are the risks with „my“ approach?这种方法的原因是什么?“我的”方法有什么风险?

EDIT: Of course i ment to specify exact version numbers until revision level for composer packages.编辑:当然我要指定确切的版本号,直到作曲家包的修订级别。 Doing so, would there still be any risks with my approach?这样做,我的方法还会有任何风险吗?

composer can be used in multiple ways and I wonder, too, why the TYPO3 docs show such a strong opinion here (without reasons?). composer 可以以多种方式使用,我也想知道为什么 TYPO3 文档在这里表现出如此强烈的观点(没有理由?)。

It refers to this model:它指的是这个model:

  • Local development system with composer for changing composer.json/composer.lock带有 composer 的本地开发系统,用于更改 composer.json/composer.lock

  • Build environment/CD pipeline runs composer install --no-dev and just copies the ready-built filesystem to the staging/live system构建环境/CD 管道运行composer install --no-dev并将现成的文件系统复制到暂存/实时系统

  • Live server without composer integrates with user data (database & /fileadmin)没有作曲家的实时服务器与用户数据集成(数据库和 /fileadmin)

This is preferred by some (me included) because it facilitates a testing step in a reproducible (build) environment.这是一些人(包括我)的首选,因为它有助于在可重现(构建)环境中进行测试步骤。 It also works well if the build step consists of more than composer (eg asset building).如果构建步骤包含的不仅仅是作曲家(例如资产构建),它也可以很好地工作。

While only for composer it wouldn't make a big difference if it would have to be installed on live (+ its dependencies), the more build steps you have the more "development" software you would have to put on live.虽然仅对于作曲家来说,如果它必须实时安装(+它的依赖项)不会有很大的不同,但是您拥有的构建步骤越多,您必须实时安装的“开发”软件就越多。 And that's probably where some drew a line and decided development -> build -> live is a much more powerful model.这可能是一些人划清界限并决定开发 -> 构建 -> 直播是更强大的 model。

While the build environment could very well be on the live server, I wouldn't want it to be in a published state ( I don't know if you refered to that).虽然构建环境很可能在实时服务器上,但我不希望它出现在已发布的 state 中(我不知道您是否提到过)。 So I would do at least some copying around (or rather symlink switching) in order to make sure that problems during build/testing do not affect the published site.所以我会至少做一些复制(或者更确切地说是符号链接切换),以确保构建/测试期间的问题不会影响已发布的站点。

Other models work, too.其他模型也可以。

When you use the composer to fetch the sources for your TYPO3 environment by composer install , then you do not know exactly which version of which TYPO3 extension you will get.当您使用 composer 通过composer install为您的 TYPO3 环境获取源代码时,您并不确切知道您将获得哪个版本的 TYPO3 扩展。 The composer.json files define a range of allowed version numbers, and not an exact version number. composer.json 文件定义了允许的版本号范围,而不是确切的版本号。 When you have a local or deployment environment, then the composer installation will give you a state extension 1 in version 1, extension 2 in version 2. Then you test everything.当您有本地或部署环境时,composer 安装将为您提供版本 1 中的 state 扩展 1,版本 2 中的扩展 2。然后您测试一切。 After 2 weeks you decide, that everything is ok. 2 周后,您决定一切正常。 But if you would use composer after 2 weeks on your live system, it could happen that extension 1 is now in version 2 which has a severe error.但是,如果您在 2 周后在您的实时系统上使用 composer,则可能会发生扩展 1 现在处于版本 2 中的情况,该版本存在严重错误。 Then a composer run would bring you this buggy version 2 of extension 1. This is not what you wanted.然后作曲家运行会给你带来这个扩展 1 的错误版本 2。这不是你想要的。

A workaround exists.存在一种解决方法。

How to install a specific version of package using Composer? 如何使用 Composer 安装特定版本的 package?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM