pastuhov/php-exec-command

Simple php command executor with param binding.
206,387 25
Install
composer require pastuhov/php-exec-command
Latest Version:1.1.0
PHP:>=5.3.0
License:GPL-2.0
Last Updated:Dec 21, 2017
Links: GitHub  ·  Packagist
Maintainer: pastuhov

php-exec-command

Build Status Scrutinizer Code Quality Code Coverage Total Downloads StyleCI

Simple php command executor with param binding.

Install

Via Composer

$ composer require pastuhov/php-exec-command

Features

  • light weight
  • param binding
  • throws an exception if return status >0
  • redirect stderr to stdout if needed

Usage

    $output = Command::exec(
        'echo {phrase}',
        [
            'phrase' => 'hello'
        ]
    );
    // $output = 'hello'

or

    $output = Command::exec(
        'echo {phrase}',
        [
            'phrase' => [
                'hello',
                'world'
            ]
        ]
    );
    // $output = 'hello world'

or

    try {
        Command::exec('locate {parody}',
            [
                'parody' => [
                    'pink_unicorn'
                ]
            ]
        );    
        
        echo "unicorn was found!";
    } catch (\pastuhov\Command\CommandException $e) {
        echo "can't find unicorn :(";
    }

By default, all arguments are escaped using escapeshellarg. If you need to pass unescaped arguments, use {!name!}, like so:

Command::exec('echo {!path!}', ['path' => '$PATH']);

Testing

$ composer test

or

$ phpunit

Security

If you discover any security related issues, please email kirill@pastukhov.su instead of using the issue tracker.

Credits

License

GNU General Public License, version 2. Please see License File for more information.

Related Packages

qruto/laravel-flora

Install and update Laravel application with single command

98,460 131
nicolasmahe/laravel-slack-output

Sends a message to Slack when something goes wrong with your Laravel application...

42,973 27
mariuzzo/laravel-translator

Laravel command that interactively helps you translate missing keys.

39,907 19
abhijitghogre/laravel-db-clear-command

Laravel artisan command to drop all database tables and rerun the migrations.

3,527 5
jrenton/laravel-5-scaffold

Fastest way to rapidly scaffold a laravel application

268 4