To export and import custom modules as a package using Vtlib in Vtiger CRM 7, you can follow these steps. This process allows you to move custom modules from one CRM instance to another.
1. Exporting Custom Module:
Step 1: Use Vtiger_Module::getInstance
to get the module you want to export.
$moduleName = 'CustomModule'; // Replace with your module name
$moduleInstance = Vtiger_Module::getInstance($moduleName);
Step 2: Call the export_Module
method to export the module as a ZIP file.
$packageFile = 'modules/' . $moduleName . '/' . $moduleName . '.zip'; // File path
if ($moduleInstance) {
$moduleInstance->export_Module($packageFile);
echo "Module exported successfully: " . $packageFile;
} else {
echo "Module does not exist.";
}
This will create a ZIP package of your module that you can download.
2. Importing Custom Module:
To import a custom module, use the Vtlib method to upload and install the module.
Step 1: First, ensure you have the exported ZIP file for the custom module.
Step 2: Use Vtiger_PackageImport
to install the module.
require_once('vtlib/Vtiger/PackageImport.php');
$package = new Vtiger_PackageImport();
$packageFile = 'path_to_zip_file/CustomModule.zip'; // Replace with the actual file path
$module = $package->import($packageFile);
if ($module) {
echo "Module imported successfully!";
} else {
echo "Failed to import module.";
}
Key Points:
- Ensure proper access permissions are given to the ZIP files for export/import.
- Custom modules may include tables, workflows, and fields, so the export process preserves the structure.
- Always back up your Vtiger instance before performing any module import/export operations.
Notes:
- If you are exporting a very large module, use Vtiger’s UI instead of script-based methods.
- This example assumes that your CRM is hosted on a platform where PHP has read/write access to the
modules
directory.
Let me know if you need more detailed explanations!
Conclusion
To simply both import as well as export custom modules as a package with the help of Vtlib in Vtiger CRM 7, then you have to follow all above-mentioned steps. This whole procedure lets you move all custom modules from any specific CRM instance to another with the best Vtiger hosting solutions.