有没有办法用composer.json安装symfony3?

时间:2016-08-16 14:28:01

标签: composer-php symfony composer.json

我的所有代码都被拆分为捆绑包,我需要使用composer.json。 现在我想用composer install安装整个项目,但是当我试用它时,symfony文件夹不会出现,我收到以下错误信息:

 [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 个答案:

答案 0 :(得分:1)

我认为你要找的是create-project

这是您安装Symfony via composer

的方法
composer create-project symfony/framework-standard-edition my_project_name

此命令执行以下步骤:

  1. 从packagist
  2. 获取symfony/framework-standard-edition的项目
  3. 下载存储库:https://github.com/symfony/symfony-standard
  4. 在新下载的项目中运行composer install
  5. 编辑:显然,对于您的用例,您必须将symfony/framework-standard-edition替换为您的项目标识符,并将其放在packagist,您自己的编写器存储库(例如,使用Toran Proxy)或register the repository中你的全球作曲家配置。

    你可能会发现更多的例子,通常作为某种骨架应用程序的一部分。

    虽然这是可行的,但它并不是出于某种原因部署应用程序的首选方式。您不能仅仅更新这样的项目来替换现有项目,这将导致停机或需要一些符号链接 - 玩杂耍,甚至有一些缺点。此外,您还必须运行所有初始设置步骤,例如每次都指定数据库连接信息。你可以解决这个问题(或手动输入所有这些参数),但是使用一个真正的部署工具,例如使用ansible,对于像这样的场景来说将是一个更好的选择。