|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace App\Controller; |
|
5
|
|
|
|
|
6
|
|
|
use App\Services\RecoveryManager; |
|
7
|
|
|
use App\Services\StreamedCommandResponseGenerator; |
|
8
|
|
|
use Shopware\Core\Framework\Log\Package; |
|
9
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
|
10
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
11
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
12
|
|
|
use Symfony\Component\HttpFoundation\StreamedResponse; |
|
13
|
|
|
use Symfony\Component\Process\Process; |
|
14
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @internal |
|
18
|
|
|
*/ |
|
19
|
|
|
#[Package('core')] |
|
20
|
|
|
class InstallController extends AbstractController |
|
21
|
|
|
{ |
|
22
|
|
|
public function __construct( |
|
23
|
|
|
private readonly RecoveryManager $recoveryManager, |
|
24
|
|
|
private readonly StreamedCommandResponseGenerator $streamedCommandResponseGenerator |
|
25
|
|
|
) { |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
#[Route('/install', name: 'install', defaults: ['step' => 2])] |
|
29
|
|
|
public function index(): Response |
|
30
|
|
|
{ |
|
31
|
|
|
return $this->render('install.html.twig'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
#[Route('/install/_run', name: 'install_run', methods: ['POST'])] |
|
35
|
|
|
public function run(Request $request): StreamedResponse |
|
36
|
|
|
{ |
|
37
|
|
|
$folder = $request->query->get('folder', 'shopware'); |
|
38
|
|
|
|
|
39
|
|
|
$finish = function (Process $process) use ($request, $folder): void { |
|
40
|
|
|
echo json_encode([ |
|
41
|
|
|
'success' => $process->isSuccessful(), |
|
42
|
|
|
'newLocation' => $request->getBasePath() . '/' . $folder . '/public/', |
|
43
|
|
|
]); |
|
44
|
|
|
}; |
|
45
|
|
|
|
|
46
|
|
|
return $this->streamedCommandResponseGenerator->run([ |
|
47
|
|
|
$this->recoveryManager->getPhpBinary($request), |
|
48
|
|
|
$this->recoveryManager->getBinary(), |
|
49
|
|
|
'composer', |
|
50
|
|
|
'create-project', |
|
51
|
|
|
'shopware/production:dev-flex', |
|
52
|
|
|
'--no-interaction', |
|
53
|
|
|
'--no-ansi', |
|
54
|
|
|
'-v', |
|
55
|
|
|
$folder, |
|
56
|
|
|
], $finish); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|