2016-08-16 124 views
1

我所有的代碼都被分割成了bundle,這是我需要的composer.json。 現在我想用composer install安裝整個項目,但是當我嘗試一下,symfony的文件夾沒有出現,我也得到了以下錯誤消息:有沒有辦法通過composer.json完成symfony3的安裝?

[RuntimeException]                      
Could not scan for classes inside "app/AppKernel.php" which does not appear to be a file nor a folder 

有沒有辦法來請求symfony的安裝檔案?

這是我composer.json

{ 
"name": "mygloriousname", 
"license": "proprietary", 
"type": "project", 
"autoload": { 
    "psr-4": { 
     "": "src/" 
    }, 
    "classmap": [ 
     "app/AppKernel.php", 
     "app/AppCache.php" 
    ] 
}, 
"autoload-dev": { 
    "psr-4": { 
     "Tests\\": "tests/" 
    } 
}, 
"require": { 
    "php": ">=5.5.9", 
    "symfony/symfony": "3.1.*", 
    "doctrine/orm": "^2.5", 
    "doctrine/doctrine-bundle": "^1.6", 
    "doctrine/doctrine-cache-bundle": "^1.2", 
    "symfony/swiftmailer-bundle": "^2.3", 
    "symfony/monolog-bundle": "^2.8", 
    "symfony/polyfill-apcu": "^1.0", 
    "sensio/distribution-bundle": "^5.0", 
    "sensio/framework-extra-bundle": "^3.0.2", 
    "incenteev/composer-parameter-handler": "^2.0" 
}, 
"require-dev": { 
    "sensio/generator-bundle": "^3.0", 
    "symfony/phpunit-bridge": "^3.0" 
}, 
"scripts": { 
    "post-install-cmd": [ 
     "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" 
    ], 
    "post-update-cmd": [ 
     "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" 
    ] 
}, 
"extra": { 
    "symfony-app-dir": "app", 
    "symfony-bin-dir": "bin", 
    "symfony-var-dir": "var", 
    "symfony-web-dir": "web", 
    "symfony-tests-dir": "tests", 
    "symfony-assets-install": "relative", 
    "incenteev-parameters": { 
     "file": "app/config/parameters.yml" 
    } 
} 
} 

回答

1

我想你要找的是create-project

這是你如何安裝Symfony via composer

composer create-project symfony/framework-standard-edition my_project_name 

此命令執行以下步驟:

  1. 採取項目symfony/framework-standard-edition從packagist
  2. 下載庫:https://github.com/symfony/symfony-standard
  3. 運行那個新下載的項目中的composer install

編輯:顯然,對於您的使用情況,您必須將symfony/framework-standard-edition替換爲您的項目標識符,並將其放在packagist,您自己的作曲家資源庫(例如,與Toran Proxy)或register the repository在您的全局作曲家配置。

通常可以找到幾個更多的示例作爲某種骨架應用程序的一部分。

雖然這是可行的,但它並不是因爲一個很好的原因而部署應用程序的首選方式。你不能只更新一個像這樣的項目,而只能替換現有的項目,這會導致停機或需要一些符號鏈接 - 雜耍,甚至有一些缺點。此外,您還需要運行所有初始設置步驟,例如每次指定數據庫連接信息。你可以解決這個問題(或者手動輸入所有這些參數),但是有一個真實的部署工具,例如使用ansible將是這樣一個場景中更好的選擇。

+0

create-project命令不是我搜索的那個,因爲我無法安裝在非空目錄中。所以作曲家無法閱讀我的composer.json。 Ansible有點制服爲我的項目:) 所以我必須檢查整個symfony的結構(排除'.gitignore'文件轉換成飯桶。 我有一口複製安裝完成後的配置文件。 但是,感謝您的詳細解答 – WebCyclone

+0

這是我在最後一段中試圖解釋的問題:composer是_just_,用於安裝依賴關係,而不是用於部署項目,我所描述的是設置項目的有限方式,但這已經在影響作曲家的目的了,更新一個已經存在的項目 - 就像你想做的那樣 - 需要在作曲家中進行大量的修改,因爲它需要它沒有設置的任務,在簡單的情況下,你可以改爲如果項目由git管理,請執行'git pull'。更常見的情況是使用部署工具:http://www.phptherightway.com/#deployment-tools。 – dbrumann

+0

這比您想象的更復雜的原因是,有時在更新項目時,除了下載新文件外,還有其他任務涉及到。例如,您可能必須重新啓動其他服務,清除緩存(不僅僅是作曲者緩存,例如在數據庫或redis/memcached中),可能會使會話無效。那些只是我頭腦中的那些。還有更多。他們中的大多數都需要對應用程序有更深入的瞭解,並且是非常具體的項目,他們通常必須按照正確的順序運行。這不是作曲家的範圍。這就是爲什麼它很難。 – dbrumann