2017 © Pedro Peláez
 

library lazyshell

Run shell commands from PHP the lazy way

image

treffynnon/lazyshell

Run shell commands from PHP the lazy way

  • Thursday, March 17, 2016
  • by Treffynnon
  • Repository
  • 1 Watchers
  • 2 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

LazyShell

A lazy way to make shell commands from PHP - handy for use from a REPL for instance. It uses my CmdWrap library underneath to provide the command building and process runners., (*1)

Installation

composer require treffynnon/lazyshell

Example

Sh::date("'+%Y-%m-%d'"); // date '+%Y-%m-%d'
$listing = Sh::ls('-lkha'); // ls -lkha

You can also modify the output by passing in a lambda or closure., (*2)

Sh::date("'+%Y-%m-%d'", function ($line) {
    return str_replace(date('Y'), '', $line);
})

The function is called against each line of output from the command., (*3)

Safety

Note that by default arguments will be passed in raw so you need to sanitise them before passing them to LazyShell. If you need escaping then you can pass in any of the CmdWrap types instead. I still would not allow user supplied variables go directly into commands though., (*4)

Sh::date(new Parameter('+%Y-%m-%d')); // date '+%Y-%m-%d'

Tests

Integration testing with phpunit and the code is also linted with php -l, phpcs and phpcpd. To run the tests you can use the following composer command:, (*5)

composer test

Licence

BSD 2 clause licence - see LICENCE.md., (*6)

The Versions

17/03 2016

dev-master

9999999-dev https://github.com/treffynnon/LazyShell

Run shell commands from PHP the lazy way

  Sources   Download

BSD

The Requires

 

The Development Requires

command console wrapper command line shell

17/03 2016

v1.0.0

1.0.0.0 https://github.com/treffynnon/LazyShell

Run shell commands from PHP the lazy way

  Sources   Download

BSD

The Requires

 

The Development Requires

command console wrapper command line shell