更新symfony项目框架的最佳策略

时间:2015-11-18 09:41:03

标签: php symfony composer-php

我有一个自定义的symfony项目和一个自定义供应商。在项目的composer.json中,类型设置为" project"。要更新我的供应商,请使用composer update。到现在为止还挺好。

但是如何更新我的项目呢?它是由作曲家create-project安装的,但我知道作曲家不存在update-project这样的内容。什么是保持我的骨骼的最佳策略"最新?使用git需要init git存储库并签出正确的分支/标记。因此,这不是我最喜欢的最终用户和发布管理解决方案。可以使用哪些其他方法来解决这种情况?

2 个答案:

答案 0 :(得分:1)

没有更好的选择,因为骨架是完全自由的。您只需添加symfony/symfony依赖项并创建自己的目录结构即可使用Symfony。

这意味着虽然大多数项目都是从骨架开始的,但项目可以调整它以满足他们的需求。此外,骨架包含的一些包可能会从项目中删除,或者项目使用与骨架不同的设置。

每次发布​​新的骨架版本时,您都可以检查差异(例如https://github.com/symfony/symfony-standard/compare/v2.7.2...v2.7.3)并检查更改并在项目中需要时将更改应用到项目中。

答案 1 :(得分:0)

我正在测试另一种方法。我已经创建了一个bash-script,它包含在安装后和更新后部分的composer.json中。我知道必须存在,但有了这个,最终用户只需要做composer update

<强> composer.json

[...]
    "scripts": {
    "post-install-cmd": [
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
      "chmod +x init_update_app && ./init_update_app"
    ],
    "post-update-cmd": [
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
      "chmod +x update_app && ./update_app"
    ]
  },
[...]

<强>安装后:

#!/bin/bash

if ! git ls-remote origin > /dev/null; then
    git init
    git remote add origin https://github.com/xxx/xxx.git
fi
git fetch --tags
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $latestTag

<强>更新后:

#!/bin/bash

git fetch --tags
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $latestTag

这种方法的任何缺点?我知道必须安装git但这不是问题。可以通过检查现有标记来改进脚本,以防止再次检出相同的标记或检查是否安装了git ...

相关问题