Process example

$IOHelper->success('The changelog was generated successfully');
        $IOHelper->note($target);

        return self::SUCCESS;
    }

    /** * @return array{date: string, author: string, authorEmail: string, authorGithub: string} */
    private function getDefaultData(): array
    {
        $process = new Process(['git', 'config', 'user.name']);
        $process->run();
        $gitUser = trim($process->getOutput());

        $process = new Process(['git', 'config', 'user.email']);
        $process->run();
        $gitEmail = trim($process->getOutput());

        return [
            'date' => (new \DateTime())->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d'),
            'author' => $gitUser,
            'authorEmail' => $gitEmail,
            

#[Package('core')] class StreamedCommandResponseGenerator
{
    /** * @param array<string> $params * @param callable(Process): void $finish */
    public function run(array $params, callable $finish): StreamedResponse
    {
        $process = new Process($params);
        $process->setEnv(['COMPOSER_HOME' => sys_get_temp_dir() . '/composer']);
        $process->setTimeout(300);

        $process->start();

        return new StreamedResponse(function D) use ($process$finish): void {
            foreach ($process->getIterator() as $item) {
                \assert(\is_string($item));
                echo $item;
                flush();
            }

            
\PHP_MAJOR_VERSION,
                \PHP_MINOR_VERSION,
                \PHP_RELEASE_VERSION,
                \PHP_EXTRA_VERSION,
            ],
            $path
        );
    }

    private function isPHPRunning(string $path): bool
    {
        $process = new Process([$path, '-v']);

        try {
            $process->run();
        } catch (ProcessSignaledException) {
            return false;
        }

        return $process->isSuccessful();
    }
}
Home | Imprint | This part of the site doesn't use cookies.