为什么开发人员提交.dist文件而不是实际的文件?
为什么开发人员会提交.dist文件而不是实际的文件?为什么开发人员提交.dist文件而不是实际的文件?
例如: https://github.com/FriendsOfPHP/PHP-CS-Fixer
.php_cs.dist
phpunit.xml.dist
https://github.com/symfony/symfony
.php_cs.dist
phpunit.xml.dist
为什么.php_cs
和phpunit.xml
致力于为.dist
文件?
代码格式规则在.php_cs.dist
,如果每个贡献者都应遵循相同的规则,为什么.dist
文件?
更新
推理背后parameter.yml.dist
是显而易见的,但是为什么特别.php_cs
不承诺?为什么有人会改变包含代码格式规则的.php_cs
?是不是.php_cs
的全部点,每个贡献者使用相同的规则来格式化他们的代码?
请回复只关注这两个文件。
,我发现我的答案在这里:https://github.com/symfony/recipes/issues/41
的区别是,如果 phpunit.xml不存在的PHPUnit将加载phpunit.xml.dist文件。所以你不需要复制它,除非你想要做特殊的东西。所以在回购 犯了phpunit.xml.dist(以及gitignore添加phpunit.xml)正要继 PHPUnit的最佳实践
落后于这些特定的文件.dist文件的原因是PHPUnit的和php-cs-fixer在没有本地文件的情况下使用.dist文件。
你可以看到.dist
文件作为模板文件。在您的具体分配上,配置可能略有不同。使用dist文件,您可以简单地将它们复制到例如phpunit.xml
并调整它以适应您的需求。 (例如设置一些特定的ENV变量等)。
小侧面说明:在Symfony的项目,另一种常见的DIST文件
app/config/parameters.yml.dist
parameter.yml.dist背后的推理很明显,但为什么.php_cs没有提交?为什么有人会改变包含代码格式规则的.php_cs?是不是每个贡献者使用相同规则来格式化他们的代码的.php_cs的全部要点? – PMoubed
因为这样做,你让你的本地(常常是“开发”)和远处的配置之间的差异。这也使您可以保护您的私人数据,而不会忘记设置所需的参数。
例如,symfony有一个“parameters.yml”文件和一个“parameters.yml.dist”文件。你的参数包含真实数据,用于你的实际环境,如果你尊重好的做法,永远不会提交,因为你会推送一个包含数据库名称,用户名,邮件主机和所有绝对敏感数据的文件(使用秘密令牌也以形式)。
所以,你有一个DIST文件,其中包含相同的密钥,但没有价值:
例子: 参数。阳明:
# This file is auto-generated during the composer install
parameters:
database_host: mysql
database_port: null
database_name: portfolio
database_user: artandor
database_password: supersecretpassword
mailer_transport: smtp
mailer_host: smtp.gmail.com
mailer_user: artandor
mailer_password: supersecretaswell
secret: 070950937b085d66fb1c59978ab9c47d4a420e32
和你的DIST文件看起来像:
# This file is a "template" of what your parameters.yml file should look like
# Set parameters here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
parameters:
database_host: 127.0.0.1
database_port: ~
database_name: symfony
database_user: root
database_password: ~
# You should uncomment this if you want to use pdo_sqlite
#database_path: '%kernel.project_dir%/var/data/data.sqlite'
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: ~
mailer_password: ~
# A secret key that's used to generate certain security-related tokens
secret: ThisTokenIsNotSoSecretChangeIt
对不起,长的帖子,想弄清楚你:)
通常的过程是推动DIST文件,然后一旦你把它拉到你的服务器上,就会产生 cp parameters.yml.dist parameters.yml
除了保护数据,其他的原因可能是在本地并部署应用程序。
再见:)
这是同样的原因php_cs.dist,你可以将本地php_cs自定义规则,文件和需要分析的,而不是使用命令行选项自定义规则和更多的目录:例如,该--dry-run
选项显示需要修复,但没有实际修改其中的文件:
$ php php-cs-fixer.phar fix /path/to/code --dry-run
可用here选项ECT,可以是集.php_cs本地文件。
请参阅[我的回答有点不同的问题](https://stackoverflow.com/a/46134516/1256452)。 – torek
“.dist”通常表示“此文件适合分发,但不适用于实际使用”。这意味着这是一个模板文件,实际的文件也可能在该存储库中被忽略。在本地克隆之后,您应该复制.dist文件,删除.dist部分,并对其进行适当更改以使软件在系统上运行。 –
parameter.yml.dist背后的推理很明显,但为什么.php_cs没有提交?为什么有人会改变包含代码格式规则的.php_cs?是不是每个贡献者使用相同规则来格式化他们的代码的.php_cs的全部要点? – PMoubed