Skip to content

Commit 1bdfe0b

Browse files
ycerutofabpot
authored andcommitted
[FrameworkBundle] Set default public directory on install assets
1 parent de1143b commit 1bdfe0b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,28 @@ protected function configure()
4646
$this
4747
->setName('assets:install')
4848
->setDefinition(array(
49-
new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'web'),
49+
new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'public'),
5050
))
5151
->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it')
5252
->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks')
53-
->setDescription('Installs bundles web assets under a public web directory')
53+
->setDescription('Installs bundles web assets under a public directory')
5454
->setHelp(<<<'EOT'
5555
The <info>%command.name%</info> command installs bundle assets into a given
56-
directory (e.g. the <comment>web</comment> directory).
56+
directory (e.g. the <comment>public</comment> directory).
5757
58-
<info>php %command.full_name% web</info>
58+
<info>php %command.full_name% public</info>
5959
6060
A "bundles" directory will be created inside the target directory and the
6161
"Resources/public" directory of each bundle will be copied into it.
6262
6363
To create a symlink to each bundle instead of copying its assets, use the
6464
<info>--symlink</info> option (will fall back to hard copies when symbolic links aren't possible:
6565
66-
<info>php %command.full_name% web --symlink</info>
66+
<info>php %command.full_name% public --symlink</info>
6767
6868
To make symlink relative, add the <info>--relative</info> option:
6969
70-
<info>php %command.full_name% web --symlink --relative</info>
70+
<info>php %command.full_name% public --symlink --relative</info>
7171

7272
EOT
7373
)
@@ -85,7 +85,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
8585
$targetArg = $this->getContainer()->getParameter('kernel.project_dir').'/'.$targetArg;
8686

8787
if (!is_dir($targetArg)) {
88-
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
88+
// deprecated, logic to be removed in 4.0
89+
// this allows the commands to work out of the box with web/ and public/
90+
if (is_dir(dirname($targetArg).'/web')) {
91+
$targetArg = dirname($targetArg).'/web';
92+
} else {
93+
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
94+
}
8995
}
9096
}
9197

0 commit comments

Comments
 (0)