ad677f66a94b4f10886ba535f8b8df59976cac02
[packages/precise/mcollective.git] / ext / action_helpers / php / README.markdown
1 A simple helper to assist with writing MCollective actions in PHP.
2
3 Given an action as below:
4
5 <pre>
6 action "echo" do
7    validate :message, String
8
9    implemented_by "/tmp/echo.php"
10 end
11 </pre>
12
13 The following PHP script will implement the echo action externally
14 replying with _message_ and _timestamp_
15
16 <pre>
17 &lt;?php
18     require("mcollective_action.php");
19
20     $mc = new MCollectiveAction();
21     $mc->message = $mc->data["message"];
22     $mc->timestamp = strftime("%c");
23     $mc->info("some text to info log on the server");
24 ?>
25 </pre>
26
27 Calling it with _mco rpc_ results in:
28
29 <pre>
30 $ mco rpc test echo message="hello world"
31 Determining the amount of hosts matching filter for 2 seconds .... 1
32
33  * [ ============================================================> ] 1 / 1
34
35
36 nephilim.ml.org                         : OK
37     {:message=>"hello world", :time=>"Tue Mar 15 19:20:53 +0000 2011"}
38 </pre>