Creating Your First ProcessMaker Package
Learn how to develop a custom package for ProcessMaker Platform to extend its functionality.
Overview
Extend ProcessMaker's functionality with custom functions and/or integrations with third-party services by developing your own package.
Requirements
The following are required or assumed to successfully create a package for ProcessMaker Platform:
Working programming knowledge
Access to ProcessMaker Platform
CLI access to a ProcessMaker instance with super user privileges. Typically, this is done in a local development environment.
Step 1: Creating the Package
First, let's start by creating a sibling directory to your ProcessMaker Platform installation folder. This example names the new directory processmaker-plugins.
For example, if your ProcessMaker installation is located at /opt/processmaker
, you can create the processmaker-plugins
directory at /opt/processmaker-plugins.
Clone and follow the instructions for setting up the package-skeleton template from our GitHub repository into your processmaker-plugins
directory.
Then edit your packages composer.json
file, similar to the below:
Next, locate the the composer.json
file for your ProcessMaker application (not to be confused with your packages composer.json file).
You can find the applications main composer.json
file at the root of the ProcessMaker application, assuming you are following along, it would be located at /opt/processmaker/composer.json
Now we need to add a reference to your package in the repositories
block of the composer.json
in order for the application to know of it's existence.
Extras
There are still a few things that will need to be fixed by hand:
You will need to rename your core controller from PackageSkeletonController.php
to your package's name (e.g. MyFirstPackageController.php
Located here, assuming you are following along: /opt/processmaker-plugins/my-first-package/src/Http/Controllers
)
Now, let's confirm that the controller name is right in addition to the filename.
Open your renamed controller and change the controller name, assuming you are following our conventions, to MyFirstPackageController
.
Step 2: Creating PHP Artisan Commands
A good practice is to make sure your install and uninstall commands work well.
Assuming the package is located within /opt/processmaker-plugins/my-first-package
you will want to edit the file /opt/processmaker-plugins/my-first-package/routes/console.php
located inside your package to set up the artisan commands.
Depending on your preference, the install and uninstall can also be object oriented and done via classes, which would be located at src/Console/Commands/Install.php
and src/Console/Commands/Uninstall.php
, respectfully.
The Install Command
Perhaps you want to install a database table with your package for specific configuration needs.
We are assuming that you might have a seeder class named MyFirstPackageSeeder
that would be responsible for seeding the database with your table and data.
The Uninstall Command
An example of an uninstall command might be to delete your packages assets when uninstalling.
Running the Artisan Commands
All artisan commands MUST be run within the ProcessMaker application root directory. E.g. /opt/processmaker
To execute the install command, you would then run this from your terminal:
To execute the uninstall command, you would then run this from your terminal:
You may want to additionally execute the following lines to completely eliminate the package from the environment:
Step 3: Building Front End Assets
If you are doing any kind of UI related work or sometimes even other backend work that you need to include npm modules, here is how you can go about it.
Make sure to add all your configuration and dependencies within your packages package.json
, located in the root directory of your package (/opt/processmaker-plugins/my-first-package
if you have been following along).
Then run your npm commands:
Step 4: The Service Provider
Finally, the service provider class is what contains the instructions that laravel will execute when your package is loaded.
Here is an example of what can be contained inside a service provider class, specifically within the boot method:
This can also be used in the install and uninstall commands above.
Last updated