Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2 web directory rename

Tags:

php

symfony

I have a Symfony 2 project and I cant rename the web dir for some reasons. I am trying to rename it to public.

According to the manual, I am suppose to change the composer.json and make sure the links in app.php and app_dev.php is correct.

But when I run app/console server:run, it shows

 The given document root directory "C:/xampp/htdocs/xxx/app/../web" does nto exists.

I have changed the composer.json, run composer install and composer update but still no luck. Here is my composer.json , as you can see I have already added "symfony-web-dir": "public" to the file.

If I rename my public folder to web, then everything is fine, but for certain reasons I can't do that.

{
"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"
    }
}

}

like image 649
user2478240 Avatar asked Jan 07 '15 02:01

user2478240


1 Answers

You can indeed change the name of the 'web' directory, but the server:run command does not expect this. As you can see in the ServerRunCommand source code (on line 77), the 'web' directory is hard-coded in there.

However, you should be able to solve this by simply providing the --docroot option when running the command:

bin/console server:run --docroot=C:/xampp/htdocs/xxx/public

(replace bin/console with the location of the console, which may be app/console if you are using the Symfony 2 structure)

like image 106
Nic Wortel Avatar answered Oct 15 '22 14:10

Nic Wortel