简体   繁体   English

Symfony-作曲家和parameters.yml

[英]Symfony - composer and parameters.yml

I wonder how should I handle this correctly. 我不知道该如何正确处理。

When I run "composer install" on the server it changes parameters.yml and then "git pull" complains that local file is changed. 当我在服务器上运行“ composer install”时,它会更改parameters.yml,然后“ git pull”会抱怨本地文件已更改。

What I do in that case is I delete remote parameters.yml file and checkout it again. 在这种情况下,我要做的是删除远程parameters.yml文件,然后再次签出。

Surely there must be a better way? 当然必须有更好的方法吗?

As already stated by @Cerad the parameters.yml file should never be checked into your git repository and further be ignored. 正如@Cerad所说的那样,切勿将parameters.yml文件检入git存储库,并进一步将其忽略。

  1. Remove parameters.yml from the repository (including history) 从存储库中删除parameters.yml (包括历史记录)

    git rm --cached app/config/parameters.yml

  2. Ignore the file in your repository 忽略存储库中的文件

    echo 'app/config/parameters.yml' | tee -a .gitignore

Afterwards re-create parameters.yml on your server and git pull will not complain anymore. 之后,在服务器上重新创建parameters.yml ,并且git pull不再抱怨。

You can prevent it adding to composer.json: 您可以阻止它添加到composer.json中:

...
"extra": {
    ...
    "incenteev-parameters": {
        "file": "app/config/parameters.yml",
        "keep-outdated": true
    },
    ...

Change app/config/parameters.yml with your parameters.yml path 使用您的parameter.yml路径更改app / config / parameters.yml

See: https://github.com/Incenteev/ParameterHandler#keeping-outdated-parameters 参见: https : //github.com/Incenteev/ParameterHandler#keeping-outdated-parameters

I'm agree with @Cerad, you shuold remove from git repository your parameter.yaml and add to .gitignore 我同意@Cerad,您应该从git仓库中删除您的parameter.yaml并添加到.gitignore

"parameters.yml is not committed to your version control. In fact, the .gitignore file that comes with Symfony prevents it from being committed." “ parameters.yml不会提交给您的版本控制。实际上,Symfony附带的.gitignore文件会阻止其提交。”

See: https://symfony.com/doc/3.4/configuration.html#the-special-parameters-yml-file 请参阅: https//symfony.com/doc/3.4/configuration.html#the-special-parameters-yml-file

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

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