Loads and manages all modules in ProcessWire.

The $modules API variable is most commonly used for getting individual modules to use their API.

// Getting a module by name
$m = $modules->get('MarkupPagerNav');

// Getting a module by name (alternate)
$m = $modules->MarkupPagerNav;

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Modules class also inherits all the methods and properties of: WireArray and Wire.

Common / Manipulation / Configuration

Common

Name Return Summary  
$modules->findByPrefix(string $prefix) array Find modules matching the given prefix (i.e. “Inputfield”)
$modules->get($key) Module, _Module or null Get the requested Module
$modules->getModule($key) Module, _Module or null Get the requested Module (with options)
$modules->getModuleFile($class) bool or string Get the path + filename (or optionally URL) for this module
$modules->getModuleInfo($class) array Returns an associative array of information for a Module
$modules->getModuleInfoVerbose($class) array Returns a verbose array of information for a Module
$modules->isInstalled(string $class) bool Is the given module name installed?

Manipulation

Name Return Summary  
$modules->delete(string $class) bool or int Delete the given module, physically removing its files
$modules->install(string $class) null or Module Install the given module name
$modules->refresh() (nothing) Refresh the modules cache
$modules->saveConfig($class, $data) bool Save provided configuration data for the given module
$modules->uninstall(string $class) bool Uninstall the given module name

Configuration

Name Return Summary  
$modules->getConfig($class) array Given a module name, return an associative array of configuration data for it
$modules->isConfigurable($class) bool, string or int Is the given module configurable?
$modules->saveConfig($class, $data) bool Save provided configuration data for the given module

Additional methods and properties

In addition to the methods and properties above, Modules also inherits the methods and properties of these classes: