Getting Started
Prerequisites
Before developing a plugin, you should have:- Understanding of PHP and object-oriented programming
- Familiarity with ITSM-NG architecture and database structure
- Knowledge of HTML, CSS, and JavaScript for UI components
- A development environment with ITSM-NG installed
- Access to ITSM-NG source code for reference
Development Environment Setup
Basic Plugin Structure
Create the following directory structure:Creating setup.php
Thesetup.php file is required and contains plugin metadata and initialization:
inc/plugin.class.php:1521-1538
Installation and Uninstallation
Install Function
Create database tables and initialize plugin data:inc/plugin.class.php:724-784
Uninstall Function
Remove all plugin data:inc/plugin.class.php:670-711
Creating Plugin Classes
Basic Item Class
Createinc/item.class.php:
inc/plugin.class.php:1307-1372
Configuration Class
Createinc/config.class.php:
Implementing Hooks
Createhook.php to handle various ITSM-NG hooks:
inc/plugin.class.php:1383-1427, 1650-1680, 1583-1595
Adding Menu Entries
Register your plugin in the menu system:Internationalization
Create translation files in thelocales/ directory:
Creating .pot Template
Creating Language Files
- Copy
myplugin.pottolocales/en_GB.po - Translate strings in the .po file
- Compile to .mo format:
Using Translations
inc/plugin.class.php:288-378
Best Practices
Naming Conventions
- Plugin directory: Lowercase, no spaces (e.g.,
myplugin) - Classes:
PluginMypluginClassname(CamelCase with plugin prefix) - Functions:
plugin_myplugin_function_name(lowercase with underscores) - Database tables:
glpi_plugin_myplugin_tablename(lowercase with underscores) - Rights:
plugin_myplugin_right(lowercase with underscores)
Security
inc/plugin.class.php:803-813
Performance
- Lazy loading: Only load classes when needed
- Caching: Use ITSM-NG’s cache system for expensive operations
- Database indexing: Add indexes to frequently queried columns
- Minimize hooks: Only implement hooks you actually need
Error Handling
Testing Your Plugin
Test Installation Process
Verify database tables are created correctly and default data is inserted.
Debugging
Enable debugging during development:Distribution
Preparing for Release
- Update version in
setup.php - Create changelog documenting changes
- Update README with installation instructions
- Test thoroughly in a clean ITSM-NG installation
- Check compatibility with target ITSM-NG versions
Packaging
Publishing
- Create a GitHub repository
- Tag releases with version numbers
- Submit to GLPI/ITSM-NG plugin directory
- Provide documentation and support channels
Next Steps
- Plugin System Overview - Understand the architecture
- Installing Plugins - Learn plugin installation
- ITSM-NG Developer Documentation - Advanced topics and API reference