To create a new symfony3 directory structure in symfony2 (> = 2.5), you must do the following:
open a shell command prompt and run the follwoing command to set the temporary variable :
Linux:
export SENSIOLABS_ENABLE_NEW_DIRECTORY_STRUCTURE=true
window:
set SENSIOLABS_ENABLE_NEW_DIRECTORY_STRUCTURE=true
version 2.5 and 2.6
the question of creating a new symfony3 directory structure is asked out of the box after setting the environment variable
version 2.7 and 2.8
The following steps are required to create a new directory structure from any version 2.7 and 2.8:
install the required version 2.7 and higher (tested with 2.7 and 2.8), which currently installs 2.7.7
composer create-project symfony/framework-standard-edition myproject "2.7.*"
then edit composer.json and add update-directory-structure :
composer.json:
--- snip --- "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" ], "update-directory-structure": [ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::defineDirectoryStructure" ] }, --- snip ---
after that just run
composer run-script update-directory-structure
answer "y" and you will end:
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::defineDirectoryStructure Would you like to use Symfony 3 directory structure? [y/N]
The console file, which is now in bin/console , must be adapted:
change
$loader = require __DIR__.'/autoload.php';
to
$loader = require __DIR__.'/../app/autoload.php';
then add the following methods to the AppKernel class in the app/appKernel.php :
public function getRootDir() { return __DIR__; } public function getCacheDir() { return dirname(__DIR__).'/var/cache/'.$this->getEnvironment(); } public function getLogDir() { return dirname(__DIR__).'/var/logs'; }
update: add an article on migration to the new directory structure
loans: @davil