Symfony 2 web目录重命名

use*_*240 9 php symfony

我有一个Symfony 2项目,由于某些原因我无法重命名web目录.我试图将其重命名为public.

根据手册,我想更改composer.json并确保app.php和app_dev.php中的链接是正确的.

但是,当我运行app/console服务器时:运行,它显示

 The given document root directory "C:/xampp/htdocs/xxx/app/../web" does nto exists.
Run Code Online (Sandbox Code Playgroud)

我已经更改了composer.json,运行composer install和composer update但仍然没有运气.这是我的composer.json,你可以看到我已经在文件中添加了"symfony-web-dir":"public".

如果我将我的公共文件夹重命名为web,那么一切都很好,但由于某些原因我不能这样做.

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "psr-0": { "": "src/" }
},
"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "~2.4",
    "doctrine/orm": "~2.2,>=2.2.3",
    "doctrine/doctrine-bundle": "~1.2",
    "twig/extensions": "~1.0",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~2.3",
    "sensio/framework-extra-bundle": "~3.0",
    "sensio/generator-bundle": "~2.3",
    "incenteev/composer-parameter-handler": "~2.0",
    "richsage/rms-push-notifications-bundle": "dev-master",
    "friendsofsymfony/user-bundle": "~1.3",
    "ircmaxell/password-compat": "~1.0.3"
},
"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"
    ],
    "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"
    ]
},
"config": {
    "bin-dir": "bin"
},
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "public",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "2.4-dev"
    }
}
Run Code Online (Sandbox Code Playgroud)

}

Nic*_*tel 16

您确实可以更改"web"目录的名称,但该server:run命令并不期望这样.正如您在ServerRunCommand源代码中看到的那样(第77行),'web'目录在那里是硬编码的.

但是,您应该能够通过--docroot在运行命令时提供选项来解决此问题:

bin/console server:run --docroot=C:/xampp/htdocs/xxx/public
Run Code Online (Sandbox Code Playgroud)

(替换bin/console为控制台的位置,app/console如果您使用的是Symfony 2结构,则可能是这样)