Sometimes you need to work with OS-level commands from your PHP application. Let’s look at how we can do this and see if we can make the Developer Experience nicer.
Let’s take a look: $command = new Process( command: ['git', 'push', 'origin', 'main'], ); $command->run(); What is wrong with this approach?
The main thing we want from our command is to be able to be returned as arguments that we can pass into a Symfony Process as a command.
Then we pass this through to the Git Command: final class GitCommand implements CommandContract { public function __construct( public readonly Git $type, public readonly array $args = [], public readonly null|string $executable = null, ) {