Download the PHP package posternak/commandeer without Composer
On this page you can find all versions of the php package posternak/commandeer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download posternak/commandeer
More information about posternak/commandeer
Files in posternak/commandeer
Package commandeer
Short Description A fluent API to execute shell commands.
License MIT
Informations about the package commandeer
Commandeer
A fluent PHP API for building and executing shell commands programmatically, for taking them under control, or in other words - commandeer them.
Installation
Install it into your project with composer:
Overview
Commandeer provides a type-safe, fluent API for constructing and executing shell commands in PHP, replacing error-prone string concatenation with chainable method calls.
ShellCommand Class
The foundation class that executes commands and captures results:
API:
run(): self- Execute the commandsucceeded(): bool- Check if exit code was 0getOutput(): array- Get output linesgetCommand(): string- Get command string
Cmd Builder - Universal Command Builder
The Cmd class provides a universal interface for building any shell command, it's the fluent API. To construct a command:
- Start with the
Cmdclass. - Call a static method whose name matches your desired executable (e.g.,
Cmd::docker()for thedockerexecutable). - Chain additional methods for CLI options and arguments, passing data as method parameters.
Method names are automatically converted to command-line syntax (underscores become dashes), and method arguments become command parameters.
Examples:
API:
Cmd::{executable}()- Start building a command for any executable->{method}()- Add command arguments (underscores become dashes)->run()- Execute the command->getCommand()- Preview command string without executing
Predefined Builders
For commonly-used tools, predefined builders eliminate the need to specify the executable name:
Available builders: Git, Composer, Rector, PHPStan, PHPCsFixer, Php, Artisan
Git Convenience Methods
The Git builder includes shortcuts for common operations:
Interactive Shell (REPL)
Commandeer ships with an interactive shell for exploring and running commands without writing a PHP script. All builder classes are available automatically — no use statements needed.
Type help once inside to get started.
License
MIT