+1 (408) 320-0380

Creating an installable extension package

Extensions allow you to add extra functionality to EspoCRM. They can be installed by Administrator panel under “Customization” section.

We will show you how to create the extension package of Project Management (PM) module described in this post Customization: How to create custom entity.

Here is a file structure of EspoCRM package:

  • /manifest.json – a file that contains extension properties;
  • /files – a directory that contains the extension files;
  • /scripts – contains the extension scripts.

Extension Properties

First of all, we have to create a configuration file named “manifest.json” to define extension properties:

{
"name": "Project Management",
"version": "1.0.0",
"acceptableVersions": [
">=3.0.0"
],
"releaseDate": "2015-02-14",
"author": "EspoCRM",
"description": "Project Management extension for EspoCRM.",
"delete": []
}

where

  • “name” – extension name;
  • “version”* – extension version;
  • “acceptableVersions”* – the list of supported EspoCRM versions;
  • “releaseDate” – release date;
  • author – author name;
  • “description” – details of the extension;
  • delete” – a list of files to be deleted when extension is installed.

* Syntax of versions is described by the v2.0.0 specification found at http://semver.org/.

Extension Files

All extension files should be placed into “files” directory. For our PM module the file structure will be:

application/Espo/Modules/PM/Controllers/*
application/Espo/Modules/PM/Entities/*
application/Espo/Modules/PM/Resources/*

Extension Scripts

For different needs EspoCRM supports the following types of scripts. All of them should be placed into “scripts” directory.

  • “BeforeInstall.php” – a script is executed before an installation process;
  • “AfterInstall.php” – executed once the installation process is finished;
  • “BeforeUninstall.php” – executed before uninstallation process;
  • “AfterUninstall.php” – executed once the uninstallation process is finished.

In our case, we will create a script to automatically add our Project entity to a main menu. We need to create a file named “AfterInstall.php” with the following code:

<?php

class AfterInstall
{
public function run($conatiner)
{
$config = $conatiner->get('config');

$tabList = $config->get('tabList');
if (!in_array('Project', $tabList)) {
$tabList[] = 'Project';
$config->set('tabList', $tabList);
}

$config->save();
}
}

At the end, we have to pack all this files into a .zip archive. That’s all. You can download the package of described extension here.

4 comments on “Creating an installable extension package
  1. Matsumoto says:

    I tried to pack an extension as zip with no success, always error 500, It’s not an Installation package.
    So, I tried repacking the PM Demo, used many zip settings, no luck.
    EspoCRM Version 4.5.0

  2. Matsumoto says:

    Updated to 4.7.0, error remains

    • Taras Machyshyn says:

      I think, you pack a wrong package. You should pack the .zip file inside the extension directory. The result should be a .zip archive where files located as “manifest.json”, “files”, etc. Perhaps, your achieve contains a folder, e.g. “my-extention/manifest.json”, “my-extention/files”.

      • Matsumoto says:

        Yes, I did so. E.g.: use this “PM-Extension” -> extract it -> repack it -> is no longer installable (error 500)
        I tried on Win and Mac with different apps, with and w/o compression but got always the same error.