没有不值得去解决的问题,也没有不值得去学习的技术!

In PHP 7.4, Execute Scripts in SemVer-Named Directories From Lowest to Highest When the Directory Name Is Non-Compliant

There is now a requirement to stop using semantic versioning for directory names. When directory names are uncontrollable, the directory list might appear as follows: custom_mobile_layout_2, p333, v1_33, v2.0.20, v2.0.21, v2.0.28, v2.1.1, v2.1.2, v2.1.3, v2.1.30, v2.1.65, v2.1.70, v2.1.90, v12.4.iuu, v324, wu_us6, zus.4m_m4bile_l4ut_2

1. Reference: In PHP 7.4, execute script files in directories one by one from lowest to highest based on semantic versioning directory names

2. There is now a requirement to stop using semantic versioning for directory names. When directory names are uncontrollable, the directory list might appear as follows: custom_mobile_layout_2, p333, v1_33, v2.0.20, v2.0.21, v2.0.28, v2.1.1, v2.1.2, v2.1.3, v2.1.30, v2.1.65, v2.1.70, v2.1.90, v12.4.iuu, v324, wu_us6, zus.4m_m4bile_l4ut_2. As shown in Figure 1.

There is now a requirement to stop using semantic versioning for directory names. When directory names are uncontrollable, the directory list might appear as follows: custom_mobile_layout_2, p333, v1_33, v2.0.20, v2.0.21, v2.0.28, v2.1.1, v2.1.2, v2.1.3, v2.1.30, v2.1.65, v2.1.70, v2.1.90, v12.4.iuu, v324, wu_us6, zus.4m_m4bile_l4ut_2
Figure 1

3. Filtering for versions less than or equal to v2.1.66, the final sorted directory results were expected to exclude non-compliant directories and retain only those in the vx.x.x format (compliant with semantic versioning), but the results did not meet expectations.

 

Plaintext

[2023-07-05 10:37:19] local.INFO: availableVersions [
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "custom_mobile_layout_2"
        }
    },
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "wu_us6"
        }
    },
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "v1_33"
        }
    },
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "v2.0.20"
        }
    },
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "v2.0.21"
        }
    },
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "v2.0.28"
        }
    },
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "v2.1.1"
        }
    },
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "v2.1.2"
        }
    },
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "v2.1.3"
        }
    },
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "v2.1.30"
        }
    },
    {
        "Modules\\ThemeStoreDb\\ThemeSetting\\ThemeVersion": {
            "version": "v2.1.65"
        }
    }
] 

4. Ultimately, I decided that even if directory names do not use semantic versioning, they still need certain rules to determine their chronological order. I referenced Laravel’s database migration design. The directory name format was adjusted to: {YY_mm_dd_H}_{feature_name}. The directory list is as follows: v2.0.20, v2.0.21, v2.0.28, v2.1.1, v2.1.2, v2.1.3, v2.1.30, v2.1.65, v2.1.70, v2.1.90, 2023_07_05_16_feature1, 2023_07_05_17_feature2, 2023_07_06_17_feature3. When determining the order, the logic is based on the presence of the v prefix (which I later found unnecessary, because version numbers starting with {YY_mm_dd_H}_ are always greater than those starting with v).

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系