I'm writing the installation code of my modular web application and I stumbled on writing the update code for the plugins.The problem I am having is: how do you know if the plugin is already installed? Developers can give their plugin a very basic name like: News. There will probably be more plugins with that name and now the system think it's the same plugin and will overwrite it.What can I provide to the plugin to make it unique when installing and knowing it's an update when a user provides a new installation package?The idea is that there is only an installation service, not an install and update.The system should be able to know if it's a new installation or a update.
How to separate different plugins with the same name
plugin architecture
You've correctly noticed that a package has a name, an author, and a version. These three uniquely identify a package. If you need to map this to a file system, you could choose a structure such as./plugins/author-id/package-id/version/This allows two authors to offer different packages under the same name, and multiple versions of one package to be installed at once. If no support for multiple versions is needed, you can drop the version level.The question is how to assign author IDs. Java uses the nice trick of simply using domain names, since they should be unique anyway. This works well if every developer can be expected to own a domain (this would seem to be the case in web application development). However, Java reverses the order of subdomains so that the hierarchically most important information is at the front of the name. The domain dev.example.com is mapped to the prefix com.example.dev.It is useful to have a file in each package that describes metadata. This file could declare information about dependencies, a summary of what this package does, an a version number.With this structure, installing or upgrading a package would work like this:The new package is unpacked into a temp directory, and the metadata is read.The directory of installed modules is searched for a package of same name from the same author. If no match is found, this package is installed.If a match was found and the version number is higher, then the old package is removed and the new package installed.Before installation, the presence of dependencies is verified.There are tons of package managers which you can steal ideas from. Take a look at CPAN (Perl), pip (Python), gem (Ruby), npm (Node.js). Each of these have some strengths and some weaknesses.