Plugins 101 - HowTo Get Started

General discussion about MantisBT Plugins

Moderators: Developer, Contributor

Post Reply
Starbuck
Posts: 219
Joined: 14 Feb 2006, 02:53
Location: USA
Contact:

Plugins 101 - HowTo Get Started

Post by Starbuck »

To Get Started ... Decide if you really need a plugin.
Search the rest of the forum to see if your challenge has been solved and how. See if someone has already pointed to a location in code where a change would help - or to an existing plugin. Post a note in this forum section to verify the need, and link back to related discussions. Links will help to validate your thoughts about making a change and encourage others to help.

So you need a plugin. First: RTM.

Start with the Admin Guide.
- Does Mantis do what you want?
- Where is the exact place "functionally" where it should do something different?
- What's required to get new functionality: A config setting? Change in code behavior? A new screen?
You must be familiar with how the software works before you can decide how to change it.
You must understand the FROM and the TO.

If you are going to do the coding, you must know PHP.
People in this forum won't teach you how to program. But for some visual changes you may just need to know CSS. Or just because you don't write code doesn't mean you can't read it. Search the source for text that's related to the functionality you desire, and post a note in this forum section to reference the file and line, and how you want things to change.

If you are not going to do this yourself:
Find someone to help - in your company, family, or neighborhood, or ask in this forum section. But be prepared to offer something to motivate someone else to do something for you.

A developer will need to go through the Developer Guide:
- You must be familiar with chapter 3, the Event System, and chapter 5, the Events Reference.
- Then to actually create a plugin, familiarize with chapter 4, the Plugin System.
- If you want to communicate with Mantis from outside, whether to send data in or to pull it out, read about the SOAP and REST APIs.

In summary on the docs: It makes sense that you need to know as much as the docs will tell you about how things work. Read everything that's there so that we all have a common base of understanding. If the docs aren't clear, suggest a change in this forum section.

Make a plan and verify it:
Verify in this forum section exactly what you would like to do and how you plan to approach it. You might get suggestions to save you time. The information you post about your challenge and your proposed solution can help someone else looking into the same area.

Don't change the core!
But ... some plugin features might require a change to the core. For example: "I want to update Slack with a ticket status whenever someone checks-in code to Subversion related to the ticket". That might require a new event to be fired when a specific kind of update is made via the REST API. That's OK, someone might volunteer to create a MantisBT ticket, and then create a pull-request on the core code that just adds an event signal in a key location to support your functionality. With that, Mantis will then call your plugin at just the right time. The problem with this however, is that we can never be sure if a change like this will be accepted at all, or within any specific amount of time. Don't rely on core changes - just know what's required for your functionality to work and make decisions about how to get the pieces in place.

Related: You may not be looking for a plugin at all. You might see that you want/need to make a change to core. Well, a change might be implemented in core if it applies to everyone, but as above, it might be better initially to hook a change to how the core behaves, and then later see if that hook can be incorporated into the core.

During this process, look for examples
Follow examples in the Developer Guide. (Post a note in this forum section to request more examples on a specific topic.) Download other plugins and look at the code. But be prepared for v1->v2 changes, and for PHP techniques that might be different now with PHP v7.

As with any other coding, create a test environment
Install your plugin, change the code to see what it does. Experiment. Learn. Just don't damage a live environment. If something doesn't work, create logs.

Finally... come back here for help when necessary
If you need to ask for help in this forum section, post the relevant portion of your code so that others can help and learn.
Post Reply