# How to create a plugin?

GenIE-Sys plugin can start as a simple file with a PHP function. All plugins are being installed in `/geniesys/plugins`. The only requirement for a plugin is that the folder name has to be the same as the menu name and `index.php` file should be available inside the plugin folder to initialize the plugin.

```
/geniesys/plugins/{pluginname}/index.php
/geniesys/plugins/{pluginname}/tool.php
```

**Hello World! Plugin**

```
/geniesys/plugins/hello/tool.php
```

1. Creat hello directory inside the plugin directory
2. Place following index.php file inside hello directory

```
<?php
//index.php
$subdir_arr = explode("/", $_SERVER['REDIRECT_URL']);
$mennu_arr = explode("<br />", $c['menu']);
$menu_exist = false;
for ($search_num = 0; $search_num < count($mennu_arr); $search_num++) {  
    if (trim(strtolower($mennu_arr[$search_num])) == strtolower($subdir_arr[count($subdir_arr) - 1]) ||      
    trim(strtolower($mennu_arr[$search_num])) == "-".strtolower($subdir_arr[count($subdir_arr) - 1])) {  
        $menu_exist = true;
    }
}
if(strtolower(basename(dirname(__FILE__)))== strtolower($subdir_arr[count($subdir_arr)-1]) && $menu_exist==true){
    $c['initialize_tool_plugin'] = true;
    $c['tool_plugin'] = strtolower($subdir_arr[count($subdir_arr) - 1]);
}
?>
```

3.) Add tool.php into the hello\_world directory. `tool.php` file will be used to write all the function related to the plugin.

```
<?php
//tool.php
echo "Hello World!";
?>
```

4.) Log into the system and add hello into the menu like shown in following figure.

![GenIE-Sys login screen](/files/-MJjQpJ2LuRsm3vNv2xZ)

5.) Navigate to `http://[server name]/geniesys/hello`

![landing page of the plugin](/files/-MJjQxrZiXnyN7JEpIip)

More details about the GenIE-Sys API is available on <https://api.plantgenie.org>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://geniesys.gitbook.io/geniesys/for-administrators/how-to-create-a-plugin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
