Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

pastuhov/php-exec-command

Open more actions menu

Repository files navigation

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.

About

Simple php command executor with param binding

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.