Files
Cactidocumentation/Plugin-Reference.md
T
2026-12-03 00:15:32 -08:00

69 lines
1.8 KiB
Markdown

# Reference Plugins
Use this example to check that Cacti can discover, install, and enable a
plugin before you add a page, hook, or database table.
## Standard Files
Cacti uses `INFO` for metadata and `setup.php` for lifecycle callbacks. Ship a
README with installation and upgrade instructions, a license, and a record of
release changes. Add an `index.php` in browsable directories if your web
server serves directory indexes. Protect each application page with Cacti's
authentication bootstrap.
## File Structure
Create this directory in a test installation. The two files below are
sufficient for the example.
```text
plugins/
myplugin/
INFO
setup.php
```
As the plugin grows, put shared functions in `lib/`, settings in `include/`,
and static images in `images/`. Keep the code in `setup.php` small because
Cacti loads it during plugin discovery.
## Contents of Files
Save the following as `plugins/myplugin/INFO`. Set the compatibility floor of
your own plugin to the oldest Cacti release you support and test.
```ini
[info]
name = myplugin
version = 1.0
longname = My First Plugin
author = Example Maintainer
homepage = https://www.cacti.net
compat = 1.2.32
```
Save the following as `plugins/myplugin/setup.php`.
```php
<?php
function plugin_myplugin_version() {
$info = parse_ini_file(__DIR__ . '/INFO', true, INI_SCANNER_RAW);
return $info['info'];
}
function plugin_myplugin_install() {
// This example has no hooks, realms, or tables to register.
}
```
Open **Console > Configuration > Plugins**. Install **My First Plugin** and
enable it. Verify that the management page shows version **1.0** and the
enabled state. This example has no user interface. To add a page or tab, see
[Creating a plugin](Plugin-Creating-Plugins.md).
---
Copyright (c) 2004-2026 The Cacti Group