2017 © Pedro Peláez
 

library exec

A Wrapper for exec and it's results

image

demvsystems/exec

A Wrapper for exec and it's results

  • Wednesday, October 4, 2017
  • by demvsystems
  • Repository
  • 3 Watchers
  • 2 Stars
  • 8,622 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 12 % Grown

The README.md

exec

exec is a wrapper for the php exec() command, which allows to build CLI commands with the help of chaining., (*1)

The Command Class

Everything starts with the Command class, which let's you create any command in the following fashion:, (*2)

echo Command::create()
  ->app('echo')
  ->input('Hello World')
  ->exec();
//prints out "Hello World"

This would create a command, which is running the application echo with the input "Hello World" and executes it right away. For a full reference on what is possible with the Command head over to the associated wiki entry., (*3)

Asynchronous Commands

You are also able to execute a command asynchronously, by appending the async() method to your command. The echo example from before would look like this:, (*4)

$async = Command::create()
  ->app('echo')
  ->input('Hello World')
  ->async()
  ->exec();

Which returns an Async object. With this object, you can do: - check if the command is still running - check if a command with a similar syntax is currently running - kill ithe command - kill every command with a similar syntax, (*5)

Of course the above example doesn't make much sense, because we will never get a look at the result. Therefor we can pipe the result into a file., (*6)

$async = Command::create()
  ->app('echo')
  ->input('Hello World')
  ->async()
  ->path('hello.txt')
  ->exec();

This will write a file called hello.txt with the content of our command, as soon as it terminates. For more on asynchronous commands have a look at the wiki page., (*7)

Application

Instead of defining every app in a string, inside of the app call, you are also able to use some of the predefined apps, which wrap away some of the repetetive work. For example take the PhpApp. Normally you would build a command like this to get the PHP version:, (*8)

Command::create()
  ->app('php')
  ->arg('v')
  ->exec();

But with the PhpApp you can get rid of the string param:, (*9)

Command::create()
  ->phpApp()
  ->arg('v')
  ->exec();

There are already some other advanced apps, which wrap away their special syntax, like the XArgsApp. For a full reference on which apps are available and how they work, have a look at the Application wiki entry., (*10)

You are also able to write your own app wrappers. Have a look at this on how to do it., (*11)

The Versions

04/10 2017

dev-master

9999999-dev https://github.com/demvsystems/exec

A Wrapper for exec and it's results

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

command exec

04/10 2017

0.2.0

0.2.0.0 https://github.com/demvsystems/exec

A Wrapper for exec and it's results

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

command exec

08/07 2016

0.1.4

0.1.4.0 https://github.com/demvsystems/exec

A Wrapper for exec and it's results

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

command exec

16/06 2016

0.1.3

0.1.3.0 https://github.com/demvsystems/exec

A Wrapper for exec and it's results

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

command exec

15/06 2016

0.1.2

0.1.2.0 https://github.com/demvsystems/exec

A Wrapper for exec and it's results

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

command exec

14/06 2016

0.1.1

0.1.1.0 https://github.com/demvsystems/exec

A Wrapper for exec and it's results

  Sources   Download

MIT

The Requires

 

The Development Requires

command exec

10/06 2016

0.1

0.1.0.0 https://github.com/demvsystems/exec

A Wrapper for exec and it's results

  Sources   Download

MIT

The Requires

 

The Development Requires

command exec