Assuming Plugin1
is their main plugin class file name, you could do:
\fully\qualified\namespace\Plugin1::getInstance()->myService->myMethod();
In order for this to work:
- Craft must be installed.
Plugin1
must be installed and enabled in Craft.
- Composer autoloading has to be working so that it knows where to find
Plugin1
If you're doing this from a custom module, then you'll need to listen for the EVENT_INIT
event, because plugins get instantiated after modules.
i.e.
Craft::$app->on(Application::EVENT_INIT, function() {
\fully\qualified\namespace\Plugin1::getInstance()->myService->myMethod();
});
$plugin
maybe you could tell us the name of the other plugin? Also it's important where you call this method. If it's in your plugins init function chances are high the other plugin is not created at this time