Jump to content

How to install Pro and commercial modules with installModule()?


Ivan Gretsky
 Share

Recommended Posts

Good day!

Is there a way to install modules that are not accessible via direct link like Pro modules and other commercial modules? It could be done by getting a module from a local path. But there seems to be no such option for this method. Am I missing something obvious? Could an install from local path option be (please))) added?

Thanks!

 

Link to comment
Share on other sites

Hi Ivan,

the installModule() method just takes the name of the module to install and that's it. At least as long as PW can find that module on the file system. But RM can also download modules for you if you provide an URL (eg the github zip link).

Did you read the usage notes of installModule? Or did you experience any other issues?


   * Install module
   *
   * If an URL is provided the module will be downloaded before installation.
   * You can provide module settings as 2nd parameter.
   * Usage:
   * $rm->installModule("YourModule");
   *
   * Install from url:
   * $rm->installModule(
   *   "TracyDebugger",
   *   "https://github.com/adrianbj/TracyDebugger/archive/refs/heads/master.zip"
   * );
   *
   * Install with settings:
   * $rm->installModule("YourModule", ['setting1'=>'foo', 'setting2'=>'bar']);
   *
   * Install with settings from url:
   * $rm->installModule("MyModule", ['setting'=>'foo'], "https://...");

 

In my projects I usually download modules via the GUI, then I commit those files into the git project. Then I add this to Site.module.php:

$rm->installModule('WhateverModuleYouDownloaded');

That means as soon as you push those changes you have all the files you need on your staging/production system and once the migration of Site.module.php is run the module will be installed without any further manual steps.

  • Like 2
Link to comment
Share on other sites

Thanks for the reply. Reading it I am happy I got the way it works right. But I need to automatically install the modules not available via url and not already installed. My use case is the initial system setup. I need some paid modules installed and do not want to do it manually, but rather in an after install script (install profile). I am thinking to have the Pro modules installation packages downloaded as zipped files and put in the web root folder or above (along with some other stuff I need during the install). I then I would install them from there with installModule(). The show-stopper is that I can't do it as there is no option to get module not from the url, but from the local path...

Ok. now I just realized that I can just extract those zips to site/modules and just run installModule() without the url param, right?

Link to comment
Share on other sites

15 hours ago, Ivan Gretsky said:

I then I would install them from there with installModule(). The show-stopper is that I can't do it as there is no option to get module not from the url, but from the local path...

Ok. now I just realized that I can just extract those zips to site/modules and just run installModule() without the url param, right?

Don't forget that, when working with RockMigrations, you can still solve problems without RockMigrations ? So you have all the PW magic available, that means you could for example just use $files->copy() to copy files, or you could use exec("cp -r /foo /bar"); That all depends on your system and situation.

RockMigrations just helps with an easy API for all the things that usually have to be done manually in the PW backend.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...