$modules->getModule() method

Get the requested Module (with options)

This is the same as $modules->get() except that you can specify additional options to modify default behavior. These are the options you can specify in the $options array argument:

  • noPermissionCheck (bool): Specify true to disable module permission checks (and resulting exception). (default=false)
  • noInstall (bool): Specify true to prevent a non-installed module from installing from this request. (default=false)
  • noInit (bool): Specify true to prevent the module from being initialized. (default=false)
  • noSubstitute (bool): Specify true to prevent inclusion of a substitute module. (default=false)
  • noCache (bool): Specify true to prevent module instance from being cached for later getModule() calls. (default=false)
  • noThrow (bool): Specify true to prevent exceptions from being thrown on permission or fatal error. (default=false)
  • returnError (bool): Return an error message (string) on error, rather than null. (default=false)

If the module is not installed, but is installable, it will be installed, instantiated, and initialized. If you don't want that behavior, call $modules->isInstalled('ModuleName') as a condition first, OR specify true for the noInstall option in the $options argument.


// basic usage
$module = $modules->getModule($key);

// usage with all arguments
$module = $modules->getModule($key, array $options = []);


keystring, int

Module name or database ID.

options (optional)array

Optional settings to change load behavior, see method description for details.

Return value

Module _Module null string

Returns ready-to-use module or NULL|string if not found (string if returnError option used).


Method can throw exceptions on error:

  • WirePermissionException or \Exception - If module requires a particular permission the user does not have

See Also

$modules methods and properties

API reference based on ProcessWire core version 3.0.135

Twitter updates

  • New post: A look at two new WireMail modules for sending email, plus details on how you can configure ProcessWire to use Gmail for sending email— More
    19 July 2019
  • New post: Version 3.0.135 of ProcessWire on the dev branch focuses on some .htaccess updates, adds clarity to debug mode, and improves upon the installer— More
    5 July 2019
  • ProcessWire 3.0.133 adds a useful new Page::meta() method for a new type of page-specific persistent data storage, adds the ability for users to create their own bookmarks in Lister, and has a handy and time saving update for the asmSelect input type— More
    14 June 2019

Latest news

  • ProcessWire Weekly #271
    In the 271st issue of ProcessWire Weekly we're going to introduce two brand new WireMail modules, a new Textformatter module from BitPoet, and a brand new markup module from Chris Thomson. Read on!
    Weekly.pw / 20 July 2019
  • Two new WireMail modules and using Gmail with PW
    A look at two new WireMail modules for sending email, plus details on how you can configure ProcessWire to use Gmail for sending email.
    Blog / 19 July 2019
  • Subscribe to weekly ProcessWire news

“…building with ProcessWire was a breeze, I really love all the flexibility the system provides. I can’t imagine using any other CMS in the future.” —Thomas Aull