dracoblue.net

Simple php task to run commandline in phing

In phing there is a task called

exec. Even though it provides a "passthru"-property it's not really possible to directly get the response from the output.

Since I wanted to have direct output of all data, I created an adhock-task called "run". You can add it to your phing build file, by adding this tag right before the usage.

<adhoc-task name="run">
class RunTest extends Task {
        private $dir;
        private $command;

        function setCommand($command) {
                $this->command = $command;
        }

        function setDir($dir) {
                $this->dir = $dir;
        }

        function main() {
                $this->log("Changing to: " . $this->dir);
                chdir($this->dir);
                $this->log("Executing: " . $this->command);
                system($this->command);
        }
}
</adhoc-task>

Remember, that this task does not check wether the directory exists and always requires it to be set. If you want to extend the task for your needs and mind to share it, feel free to post a reply!

In phing, php by @ 23 Sep 2009

comments powered by Disqus

Recent Files

Advertisement

Recent Dev-Articles

Read recently

About

Blogroll