PHP code example of treehousetim / command

1. Go to this page and download the library: Download treehousetim/command library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

treehousetim / command example snippets




$command = new \treehousetim\command\command();
$command
	->command( 'ls' )
	->arg( '-lah' );

echo $command->getExecutableString();

// output:
// ls '-lah'



echo \treehousetim\command\command::factory()
->command( 'ls' )
	->arg( '-lah' )
->pipeCommand(
	command::factory()
		->command( 'more' )
	)
->getExecutableString();

// output:
// ls '-lah' | more



echo $command->commandLog[0];



use \treehousetim\command\command;

$log = new \Monolog\Logger( 'My Example Program' );
$log->pushHandler( new StreamHandler( './example.log', \Monolog\Logger::DEBUG ) );

$command = command::factory( $log )
	->command( 'ls' )
	->arg( '-lah' )
	->exec();

$output = $command->exec();

echo $command->commandLog[0];
echo PHP_EOL;
echo $output