Overview
A FacturaScripts plugin is a self-contained package that can add new features, modify existing functionality, or integrate external services. Plugins are stored in thePlugins/ directory and are managed through the admin interface.
Plugin Requirements
- FacturaScripts 2025 or higher
- PHP 8.0 or higher (configurable per plugin)
- A unique plugin name (alphanumeric, no spaces)
- A valid
facturascripts.inifile
Creating Your First Plugin
Step 1: Create the Plugin Directory
Create a new directory inPlugins/ with your plugin name:
Plugin names must be alphanumeric and should follow PascalCase convention (e.g.,
MyPlugin, SalesReport, CustomInvoice).Step 2: Create facturascripts.ini
Every plugin must have afacturascripts.ini file in its root directory:
name: Exact plugin name (must match directory name)description: Brief description of the pluginversion: Plugin version numbermin_version: Minimum FacturaScripts version requiredmin_php: Minimum PHP version required (default: 8.0)require: Comma-separated list of required pluginsrequire_php: Comma-separated list of required PHP extensions
Step 3: Create the Init Class (Optional)
TheInit.php class handles plugin lifecycle events:
Step 4: Define Your Plugin Structure
A typical plugin structure:Installing Your Plugin
Method 1: Direct Installation
- Copy your plugin folder to
Plugins/ - Navigate to Admin > Plugins in FacturaScripts
- Find your plugin in the list
- Click Enable
Method 2: ZIP Installation
-
Create a ZIP file with your plugin folder inside:
-
The ZIP structure must be:
- Upload via Admin > Plugins > Upload Plugin
The
facturascripts.ini file must be in a single root directory within the ZIP. Multi-directory ZIPs will be rejected.Plugin Lifecycle
Enable Process
- FacturaScripts checks plugin compatibility (min_version, min_php)
- Verifies all dependencies are installed
- Marks plugin as enabled in
MyFiles/plugins.json - Calls
Init::update()method - Deploys plugin assets and routes
- Calls
Init::init()on subsequent requests
Disable Process
- Marks plugin as disabled
- Calls
Init::uninstall()method - Redeploys system without plugin assets
- Removes plugin routes
Update Process
- Extracts new version over existing plugin
- Marks
post_enable = trueif plugin was already enabled - Calls
Init::update()to run migrations - Redeploys assets and routes
Plugin Dependencies
Specify required plugins infacturascripts.ini:
- Prevent enabling your plugin if dependencies are not installed
- Show a warning about missing dependencies
- Ensure dependency plugins load before yours
Best Practices
Namespace Convention
Always use
FacturaScripts\Plugins\YourPlugin as the base namespaceAvoid Core Modifications
Never modify core files. Use extensions and events instead
Version Control
Keep your plugin in Git and increment version numbers on changes
Test Thoroughly
Test enabling, disabling, and updating your plugin
Testing Your Plugin
- Fresh Installation: Test enabling the plugin on a clean FacturaScripts installation
- With Data: Test with existing data to ensure compatibility
- Update Path: Test updating from a previous version
- Dependencies: Test with and without required plugins
- Disable/Enable: Test disabling and re-enabling the plugin
Next Steps
Plugin Structure
Learn about directory structure and configuration
Controllers
Create custom controllers for your plugin
Models
Define data models and database tables
Views
Create user interfaces with XMLViews
Common Issues
Plugin not appearing in list
Plugin not appearing in list
- Ensure
facturascripts.iniexists in the plugin root - Check that the plugin name in the INI matches the folder name
- Verify file permissions (must be readable by web server)
Cannot enable plugin
Cannot enable plugin
- Check
min_versionis not higher than your FacturaScripts version - Verify all required plugins are installed and enabled
- Check PHP version meets
min_phprequirement - Review error logs for specific compatibility issues
Plugin enabled but not working
Plugin enabled but not working
- Check namespace declarations match plugin name
- Verify class names follow FacturaScripts conventions
- Run
Deployfrom admin panel to refresh routes - Check error logs for PHP errors

