Download the PHP package demvsystems/exec without Composer
On this page you can find all versions of the php package demvsystems/exec. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download demvsystems/exec
More information about demvsystems/exec
Files in demvsystems/exec
Package exec
Short Description A Wrapper for exec and it's results
License MIT
Homepage https://github.com/demvsystems/exec
Informations about the package exec
exec
exec is a wrapper for the php command, which allows to build CLI commands with the help of chaining.
The Command Class
Everything starts with the Command class, which let's you create any command in the following fashion:
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.
Asynchronous Commands
You are also able to execute a command asynchronously, by appending the method to your command. The echo example from before would look like this:
Which returns an 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
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.
This will write a file called with the content of our command, as soon as it terminates. For more on asynchronous commands have a look at the wiki page.
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:
But with the PhpApp you can get rid of the string param:
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.
You are also able to write your own app wrappers. Have a look at this on how to do it.