How to make plugin for package?

Permalink 1 user found helpful
Hello.

Can anyone share thoughts on how to handle and make a plug-in for a package? I have a package and want to make a stand alone plugin package for it. How do I go about it from the installation point of view? That is, do I copy the plugin files into the installed package during the plugin installation and then delete them on uninstalling the plugin or how else?

I don't want to have 2 separate packages: one without the plugin and one with it. And I don't want to make a new revision of the package with the plugin functionality, I want it to be installed separately if needed.

Any thoughts, suggestions, ideas?

Thank you.

linuxoid
 
linuxoid replied on at Permalink Reply
linuxoid
bump
hutman replied on at Permalink Reply
hutman
Plugin isn't a concrete5 term so it's hard to give direction about this. Can you be more specific what you are trying to accomplish?
linuxoid replied on at Permalink Reply
linuxoid
Say, I developed a big application package. And now I thought of an additional functionality for it which may not be need for all and which I'd rather separately develop and sell on the Marketplace as a plug-in rather than updating the whole application. I just can't get my head around how the package and the plugin can be integrated without writing php files during the plugin installation. This can be a big mess for install/update/uninstall.
hutman replied on at Permalink Reply
hutman
So you're looking to build two packages that work together, but the second one relies on the first?
linuxoid replied on at Permalink Reply
linuxoid
Yes, exactly.

The plugin will know about the package's functionality. But the package wouldn't have a clue about the plugin. The plugin will have to override some package's functionality and views. I've got no idea how or if that could be implemented.
hutman replied on at Permalink Reply
hutman
I don't know how you would override the functionality from one to the other.

You should be able to build your second package with a check on the install to make sure the first package is installed and then use it's functionality as you normally would.

This package has as example of the install check for another package - https://www.concrete5.org/marketplace/addons/page-redirect1...
mnakalay replied on at Permalink Best Answer Reply
mnakalay
I actually did exactly that on my Ajax for express package that comes as a light and pro version. The pro version requires the light version to be installed and overrides one of its classes.

Because the plugin package will always be installed after the main package, its code will also always be loaded after the main package's code so you can easily override any of the main classes by using Laravel's bind() in your plugin's controller on_start() funciton

$app->bind('\Your\main\class\from\main\package', '\Your\override\class\from\plugin\package');
linuxoid replied on at Permalink Reply
linuxoid
This is awesome! I'll definitely try this. Thank you very much.
linuxoid replied on at Permalink Reply
linuxoid
What about overriding a block and Dashboard page functionality? Is that possible?

If I use the same single pages and blocks in the later (plugin) package, will they override all those in the original?