我有一个Symfony 2.1项目,通过composer安装了其他软件包.我想将它部署到我的生产服务器,但我想知道我是否需要更改composer.json文件中的任何内容.这是我目前的文件内容:
{ "name": "symfony/framework-standard-edition","description": "The \"Symfony Standard Edition\" distribution","autoload": { "psr-0": { "": "src/" } },"require": { "PHP": ">=5.3.3","symfony/symfony": "2.1.1","doctrine/orm": ">=2.2.3,<2.4-dev","doctrine/doctrine-bundle": "1.0.*","twig/extensions": "1.0.*","symfony/assetic-bundle": "2.1.*","symfony/swiftmailer-bundle": "2.1.*","symfony/monolog-bundle": "2.1.*","sensio/distribution-bundle": "2.1.*","sensio/framework-extra-bundle": "2.1.*","sensio/generator-bundle": "2.1.*","jms/security-extra-bundle": "1.2.*","jms/di-extra-bundle": "1.1.*","friendsofsymfony/user-bundle": "*","knplabs/knp-paginator-bundle": "dev-master","ornicar/gravatar-bundle": "dev-master","liip/url-auto-converter-bundle": "dev-master" },"scripts": { "post-install-cmd": [ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap","Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache","Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets","Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" ],"post-update-cmd": [ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap","Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" ] },"config": { "bin-dir": "bin" },"minimum-stability": "dev","extra": { "symfony-app-dir": "app","symfony-web-dir": "web" } }
我应该更改最小稳定性设置吗?
我应该将每个要求修复为单个版本,没有通配符,还是“dev-master”?
我应该在http://packagist.org/上搜索每个依赖项的最后一个稳定版本吗?
解决方法
我认为最重要的是你的composer.lock,而不是composer.json.
在测试服务器上部署您的应用程序,PHP composer.phar安装,然后运行测试以确保一切正常.如果确实没问题,只需与composer.lock一起部署在生产服务器上.
这样您的deps将与测试服务器相同.如果您有多个前端服务器,这也很有用,composer.lock将确保每个人都使用完全相同的代码.
你说
Should I fix every requirement to a single version,without wildcard,or “dev-master”?
这是composer.lock的作用,用于“修复”所有内容. composer.json是关于声明依赖项,并处理版本之间可能存在的不兼容性.默认情况下,您应该坚持使用稳定版本,除非您在开发分支中需要一些奇特的新功能,或者尚未合并的错误修正.
因此,您应该对composer.lock进行版本控制,这样可以更轻松地进行自动部署.