2012-09-11 23 views
7

我有一個Symfony 2.1項目,通過作曲家安裝了附加的軟件包。我想將其部署到我的生產服務器,但我想知道是否需要更改composer.json文件中的任何內容。以下是我當前的文件內容:我的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::clearCache", 
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", 
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" 
     ] 
    }, 
    "config": { 
     "bin-dir": "bin" 
    }, 
    "minimum-stability": "dev", 
    "extra": { 
     "symfony-app-dir": "app", 
     "symfony-web-dir": "web" 
    } 
} 

我應該更改minimum-stability設置嗎?

我是否應該將每個要求修正爲單個版本,沒有通配符或「dev-master」?

我應該在http://packagist.org/上搜索每個依賴項的最後一個穩定版本嗎?

回答

11

我認爲最重要的是你的composer.lock,而不是composer.json。

在測試服務器上部署您的應用,php composer.phar install,然後運行測試以確保一切正常。如果確實如此,只需在生產服務器上與composer.lock一起部署即可。

這樣你的代表將與您的測試服務器相同。如果你有多個前端服務器,這也是有用的,composer.lock將確保每個人都使用完全相同的代碼。

你說

我應該修正到一個單一版本的各種要求,沒有通配符,或「DEV-大師」?

這是composer.lock的作用,「修復」一切。 composer.json是關於聲明依賴關係,並處理版本之間可能的不兼容問題。默認情況下,應該堅持使用穩定版本,除非在開發分支中需要一些奇特的新功能,或者尚未合併的修補程序。

因此,您應該爲您的composer.lock版本進行版本管理,這對於自動部署更爲簡單。

+0

很好的答案,但你能詳細說明「部署你的應用程序」的步驟嗎?我需要哪些作曲家文件?很明顯,.phar和.lock文件。我還需要composer.json嗎?那麼composer_installer.php呢? –

+1

@BenjaminBrizzi我不能詳細說明「部署你的應用程序」。作曲家只關心依賴關係,而不是你的應用程序本身。通常,「部署你的應用程序」可以是'git clone'。您仍然需要'composer.json',因爲它包含了deps列表。 'composer.lock'只指定你想要安裝的版本。我不知道composer_installer.php是什麼,對不起。 –

相關問題