Source: juststeveking.uk

Working with OS process in PHP
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, ) {
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners