简体   繁体   English

使用Flex创建了新的Symfony 3.4项目-这真的是Symfony 3.4吗?

[英]Created new Symfony 3.4 project using Flex - Is this really Symfony 3.4?

The question: 问题:

Is a Symfony 3.4 project created with the Flex installer really Symfony 3.4 ? 使用Flex安装程序创建的Symfony 3.4项目真的是Symfony 3.4吗? Or more a "Symfony 4 project with 3.4 core files? 还是带有3.4个核心文件的“ Symfony 4项目”?

The complete story: 完整的故事:

I am working on migrating an existing Symfony 2.8 project to Symfony 3.4 . 我正在将现有的Symfony 2.8项目迁移到Symfony 3.4 At first I created a new Symfony 3.4 project using the Symfony installer: 首先,我使用Symfony安装程序创建了一个新的Symfony 3.4项目:

symfony new MyProject 3.4

The file and folder structure is a bit different to Symfony 2.8 but overall everything is quite similar. 文件和文件夹的结构与Symfony 2.8略有不同,但总体来说都非常相似。 It was not too difficult to migrate the config, files, etc. from the existing 2.8 project. 从现有的2.8项目中迁移配置,文件等并不是太困难。

However, after some more research I thought it might be a good idea to start the new 3.4 project using the recommended Flex installer instead. 但是,经过更多研究之后,我认为最好使用推荐的Flex安装程序启动新的3.4项目。 This would give me the new folder structure which is also used in Symfony 4 , which might make a future migration to this version easier. 这将为我提供一个新的文件夹结构,该结构也将在Symfony 4 ,这可能使将来向该版本的迁移更加容易。

composer create-project symfony/skeleton:3.4.* MyProject

Of course the directory structure is different in this project. 当然,该项目中的目录结构是不同的。 But not only the folders are different but almost everything. 但是,不仅文件夹不同,而且几乎所有内容都不同。 The way the complete config is organized, how the routes are defined and managed, how bundles are organized (none at all), how parameters are defined and used, etc. 完整配置的组织方式,路由的定义和管理方式,捆绑的组织方式(根本没有),参数的定义和使用方式等。

There is almost nothing left that looks like Symfony 3.4 . 几乎没有任何东西看起来像Symfony 3.4 This seems to be a Symfony 4 setup where only the files in vendor/symfony/... are from version 3.4 这似乎是一个Symfony 4设置,其中只有vendor/symfony/...中的文件来自版本3.4

Migrating the 2.8 project to this setup would be way more complex. 将2.8项目迁移到此设置将更加复杂。

Of course I know that a lot has changed in Symfony 4 while Symfony 3.4 is still quite similar to Symfony 2.8 . 当然,我知道Symfony 4发生了很多变化,而Symfony 3.4仍然与Symfony 2.8非常相似。 But how is it possible that two Symfony 3.4 installations are so dramatically different? 但是,两个Symfony 3.4安装怎么可能有如此大的不同?

I understood that Flex is a new workflow to manage projects but shouldn't be the end result - a new Symfony 3.4 project - be more or less the same no matter which workflow / install was used to create it? 我知道Flex是一个用于管理项目的新工作流程,但无论使用哪个工作流程/安装来创建它,都不应该成为最终结果-一个新的Symfony 3.4项目-大致相同。

Flex is more powerful when setting up and managing different project. 在设置和管理不同的项目时,Flex功能更强大。 However I want to setup the project once and run it for several years. 但是我想一次设置该项目并运行几年。 Is there any advantage (in the near future) in proceeding with the Flex approach? 在不久的将来采用Flex方法是否有任何优势?

To answer your first question: Yes, a Symfony 3.4 project created using Flex is indeed a 3.4 project. 要回答第一个问题:是的,使用Flex创建的Symfony 3.4项目确实是3.4项目。 "bin/console --version" will verify this. “ bin / console --version”将对此进行验证。

As far as the directory structure goes, Symfony tries to strike a balance between maintaining backwards compatibility but at the same time keep moving forward and refining their design. 就目录结构而言,Symfony试图在保持向后兼容性与同时保持前进与完善其设计之间寻求平衡。 For information on why things were done, it is useful to keep an eye in the Symfony blog and perhaps visit the slack channel. 有关为何执行此操作的信息,请密切关注Symfony博客并访问松弛的频道。 Especially the posts when Flex was introduced as well as the new directory structure. 特别是引入Flex时的帖子以及新的目录结构。

One goal for Symfony is to make it as easy as possible to migrate from a long term support version to a newer version. Symfony的一个目标是使从长期支持版本到较新版本的迁移尽可能容易。 Hence 2.8 is pretty much identical to 3.0 except that a bunch of depreciated functionality was removed. 因此,2.8与3.0几乎相同,只是删除了许多折旧的功能。 If you were following things at the time you would have noticed that there was quite a big jump between 2.7 and 2.8. 如果您当时在关注这些事情,您会注意到2.7和2.8之间有很大的跳跃。

Same for 3.4 to 4.0 being easy but a few possible bumps going from 3.0 to 3.4. 对于3.4到4.0一样简单,但是从3.0到3.4可能会有一些颠簸。

Kind of meandered a bit. 有点曲折。 Sorry. 抱歉。

To address your second question of the value of using Flex, like all opinion based questions the only correct answer is: it depends. 与所有基于意见的问题一样,要解决使用Flex的价值的第二个问题,唯一正确的答案是:它取决于。

In my case the choice to use the new directory structure was easy. 就我而言,使用新目录结构的选择很容易。 I have a number of apps and use Symfony on a daily basis. 我有许多应用程序,并且每天使用Symfony。 Keeping up with the latest and greatest makes sense for me. 跟上最新和最伟大的事情对我来说很有意义。 Spending the time to port apps (some of them dating back to 2.3) to 4.0 makes my overall maintenance burden easier. 花时间将应用程序(其中一些可追溯到2.3)移植到4.0,使我的整体维护负担变得更加轻松。 The time spent experimenting how to port helped me understand the new functionality. 尝试如何移植的时间帮助我了解了新功能。 Once I got comfortable with the process it was really just copy/paste/rename exercise for the most part. 一旦我适应了这一过程,实际上大部分时间只是在复制/粘贴/重命名练习。 The hardest was making sure some of the 3rd party dependencies were properly updated. 最难的是确保某些第三方依赖项已正确更新。

In your case, it seem like you only have one app and you just want to get it updated and then forget about it for a few years. 在您的情况下,您似乎只有一个应用程序,并且只想更新它,然后忘记了几年。 In that case, keep the old structure and move on. 在这种情况下,请保留旧结构并继续前进。 At some point you might need to move to the new structure but waiting a few years won't hurt anything. 在某些时候,您可能需要使用新的结构,但是等待几年不会对您造成任何伤害。 And hey, I suspect 5.0 will introduce more changes. 嘿,我怀疑5.0会带来更多变化。

The choice is yours. 这是你的选择。

Symfony Flex is the new way to install and manage Symfony applications. Symfony Flex是安装和管理Symfony应用程序的新方法。 Flex is not a new Symfony version, but a tool that replaces and improves the Symfony Installer and the Symfony Standard Edition. Flex不是新的Symfony版本,而是替代和改进Symfony安装程序和Symfony标准版的工具。

Symfony Flex automates the most common tasks of Symfony applications, like installing and removing bundles and other Composer dependencies. Symfony Flex可以自动执行Symfony应用程序中最常见的任务,例如安装和删除捆绑软件以及其他Composer依赖项。 Symfony Flex works for Symfony 3.3 and higher. Symfony Flex适用于Symfony 3.3及更高版本。 Starting from Symfony 4.0, Flex should be used by default, but it is still optional. 从Symfony 4.0开始,默认情况下应使用Flex,但它仍然是可选的。

Source : https://symfony.com/doc/3.4/setup/flex.html 来源: https : //symfony.com/doc/3.4/setup/flex.html

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

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