+44 (203) 695-03-80

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*