{"id":9190,"date":"2024-09-23T06:52:20","date_gmt":"2024-09-23T06:52:20","guid":{"rendered":"https:\/\/www.infinitivehost.com\/knowledge-base\/?p=9190"},"modified":"2024-09-23T07:37:48","modified_gmt":"2024-09-23T07:37:48","slug":"export-import-custom-modules-in-vtiger-7-with-php","status":"publish","type":"post","link":"https:\/\/www.infinitivehost.com\/knowledge-base\/export-import-custom-modules-in-vtiger-7-with-php\/","title":{"rendered":"Export &amp; Import Custom Modules in Vtiger 7 with PHP"},"content":{"rendered":"<div class='epvc-post-count'><span class='epvc-eye'><\/span>  <span class=\"epvc-count\"> 2,137<\/span><span class='epvc-label'> Views<\/span><\/div>\n<p>To export and import custom modules as a package using <strong>Vtlib<\/strong> in Vtiger CRM 7, you can follow these steps. This process allows you to move custom modules from one CRM instance to another.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>Exporting Custom Module:<\/strong><\/h3>\n\n\n\n<p><strong>Step 1:<\/strong> Use <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">Vtiger_Module::getInstance<\/mark><\/code> to get the module you want to export.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">$moduleName = 'CustomModule'; \/\/ Replace with your module name\n$moduleInstance = Vtiger_Module::getInstance($moduleName);<\/mark><\/code><\/code><\/pre>\n\n\n\n<p><strong>Step 2:<\/strong> Call the <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">export_Module<\/mark><\/code> method to export the module as a ZIP file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">$packageFile = 'modules\/' . $moduleName . '\/' . $moduleName . '.zip'; \/\/ File path\nif ($moduleInstance) {\n    $moduleInstance->export_Module($packageFile);\n    echo \"Module exported successfully: \" . $packageFile;\n} else {\n    echo \"Module does not exist.\";\n}<\/mark><\/code><\/code><\/pre>\n\n\n\n<p>This will create a ZIP package of your module that you can download.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>Importing Custom Module:<\/strong><\/h3>\n\n\n\n<p>To import a custom module, use the Vtlib method to upload and install the module.<\/p>\n\n\n\n<p><strong>Step 1:<\/strong> First, ensure you have the exported ZIP file for the custom module.<\/p>\n\n\n\n<p><strong>Step 2:<\/strong> Use <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">Vtiger_PackageImport<\/mark><\/code> to install the module.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">require_once('vtlib\/Vtiger\/PackageImport.php');\n\n$package = new Vtiger_PackageImport();\n$packageFile = 'path_to_zip_file\/CustomModule.zip'; \/\/ Replace with the actual file path\n\n$module = $package->import($packageFile);\n\nif ($module) {\n    echo \"Module imported successfully!\";\n} else {\n    echo \"Failed to import module.\";\n}<\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Key Points:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Ensure proper access permissions<\/strong> are given to the ZIP files for export\/import.<\/li>\n\n\n\n<li>Custom modules may include <strong>tables, workflows, and fields<\/strong>, so the export process preserves the structure.<\/li>\n\n\n\n<li><strong>Always back up<\/strong> your Vtiger instance before performing any module import\/export operations.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Notes:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you are exporting a very large module, use Vtiger\u2019s UI instead of script-based methods.<\/li>\n\n\n\n<li>This example assumes that your CRM is hosted on a platform where PHP has read\/write access to the <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">modules<\/mark><\/code> directory.<\/li>\n<\/ul>\n\n\n\n<p>Let me know if you need more detailed explanations!<\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>To simply both import as well as export custom modules as a package with the help of\u00a0Vtlib 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 <a href=\"https:\/\/www.infinitivehost.com\/managed-vtiger-solutions\"><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\"><strong>best Vtiger hosting solutions<\/strong><\/mark><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2,137 Views 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. Step 2: Call [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[204],"tags":[],"class_list":["post-9190","post","type-post","status-publish","format-standard","hentry","category-vtiger-solutions"],"_links":{"self":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=9190"}],"version-history":[{"count":2,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9190\/revisions"}],"predecessor-version":[{"id":9195,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9190\/revisions\/9195"}],"wp:attachment":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=9190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=9190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=9190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}