runJSON example

    public function run(Request $request): Response
    {
        $version = $request->query->get('shopwareVersion', '');

        $shopwarePath = $this->recoveryManager->getShopwareLocation();

        ProjectComposerJsonUpdater::update(
            $shopwarePath . '/composer.json',
            $version
        );

        return $this->streamedCommandResponseGenerator->runJSON([
            $this->recoveryManager->getPhpBinary($request),
            '-dmemory_limit=1G',
            $this->recoveryManager->getBinary(),
            'update',
            '-d',
            $shopwarePath,
            '--no-interaction',
            '--no-ansi',
            '--no-scripts',
            '-v',
            '--with-all-dependencies', // update all packages
$response->sendContent();

        $content = ob_get_clean();

        static::assertSame('foo', trim((string) $content));
    }

    public function testRunJSON(): void
    {
        $generator = new StreamedCommandResponseGenerator();

        $response = $generator->runJSON(['echo', 'foo']);

        ob_start();
        $response->sendContent();

        $content = ob_get_clean();

        static::assertSame('foo' . \PHP_EOL . '{"success":true}', $content);
    }
}
Home | Imprint | This part of the site doesn't use cookies.