Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create symlink to setup wizard con compile command to avoid 404 error when /pub directory is configured as root path #16151

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions setup/src/Magento/Setup/Console/Command/DiCompileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Magento\Framework\Console\Cli;
use Symfony\Component\Process\Process;

/**
* Command to run compile in single-tenant mode
Expand Down Expand Up @@ -136,6 +137,8 @@ private function checkEnvironment()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->generateSetupFolderInPublic($output);

$errors = $this->checkEnvironment();
if ($errors) {
foreach ($errors as $line) {
Expand Down Expand Up @@ -400,4 +403,29 @@ private function getOperationsConfiguration(

return $operations;
}

private function generateSetupFolderInPublic(OutputInterface $output)
{
$output->writeln('<info>Generating symlink for setup.</info>');

$setupPath = $this->directoryList->getPath(DirectoryList::ROOT) . '/' . DirectoryList::SETUP;
$setupPublicPath = $this->directoryList->getPath(DirectoryList::PUB) . '/' . DirectoryList::SETUP;

if (file_exists($setupPublicPath)) {
$output->writeln('<info>Setup folder already exists in public.</info>');
return;
}

$process = new Process('ln -s ' . $setupPath . ' ' . $setupPublicPath);

$process->run();
if (!$process->isSuccessful()) {
$output->writeln('<error>' . trim($process->getErrorOutput()) . '</error>');
$output->writeln('<error>Failed to generate the symlink for setup.</error>');
return;
}

$output->writeln('<info>Generated symlink for setup in public.</info>');
}

}