From 1884544c1e237a4fc8fe5c24631f66149368d9e5 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Thu, 6 Mar 2025 10:12:28 +0100
Subject: [PATCH] update docs: add embed infos

---
 docs/30_Usage.md                  |  2 +-
 docs/40_Embed.md                  | 32 +++++++++++++++++++++++++++++++
 docs/{40_Build.md => 50_Build.md} |  6 ++++--
 3 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 docs/40_Embed.md
 rename docs/{40_Build.md => 50_Build.md} (93%)

diff --git a/docs/30_Usage.md b/docs/30_Usage.md
index 9fa5cfd..8b4a142 100644
--- a/docs/30_Usage.md
+++ b/docs/30_Usage.md
@@ -1,7 +1,7 @@
 ## Show help
 
 ```text
-./src/amcli -h
+./amcli -h
 IML Appmonitor as CLI client 0.2
 
 This client performs appmonitor checks and puts the results as JSON to stdout.
diff --git a/docs/40_Embed.md b/docs/40_Embed.md
new file mode 100644
index 0000000..669ee6e
--- /dev/null
+++ b/docs/40_Embed.md
@@ -0,0 +1,32 @@
+## Introduction
+
+To embed the cli tool into your web application you need to
+
+* perform the execution of the binary with referencing the ini `<PATH>amcli --ini=<INI-FILE>`
+* catch exitcode and output of STDOUT
+* check returncode: 
+  * if it is `0` then the excution was successful - we have a result. You can send the JSON after setting the content type as http response header
+  * if it is `> 0` the response is no JSON syntax. You should send the output that the error is seen in the appm nitor server.
+
+## PHP
+
+This code snippet is for demonstration purposes only. A PHP web app should use the PHP client - see <https://os-docs.iml.unibe.ch/appmonitor/PHP_client/index.html>
+
+```php
+<?php
+
+$AMCLI=__DIR__.'/../built_packages/amcli';
+$INI=__DIR__.'/../src/simple.ini';
+
+$sCommand="$AMCLI --ini='$INI'";
+$aOut=[];
+
+exec($sCommand, $aOut, $iRc);
+
+if($iRc==0){
+    header('Content-type: application/json');
+}else{
+    echo "Error: occured...\n";
+}
+echo implode("\n", $aOut);
+```
diff --git a/docs/40_Build.md b/docs/50_Build.md
similarity index 93%
rename from docs/40_Build.md
rename to docs/50_Build.md
index e137f50..e6813f1 100644
--- a/docs/40_Build.md
+++ b/docs/50_Build.md
@@ -1,11 +1,11 @@
 ## Requirements
 
-To update and test the command line tool you need 
+To update and test the command line tool you need
 
 * git
 * a local PHP8 cli.
 
-## Prepare environemnt
+## Prepare environment
 
 ### Get sources
 
@@ -22,6 +22,8 @@ You get this initial structure:
 ```txt
 .
 ├── build.php
+├── examples
+    └── embed_example.php
 ├── inc_functions.php
 ├── inc_vars.php
 ├── installer.php
-- 
GitLab