Wire is the base class for most ProcessWire classes and modules.

Wire derived classes have a $this->wire() method that provides access to ProcessWire's API variables. API variables can also be accessed as local properties in most cases. Wire also provides basic methods for tracking changes and managing runtime notices specific to the instance.

Wire derived classes can specify which methods are "hookable" by precending the method name with 3 underscores like this: ___myMethod(). Other classes can then hook either before or after that method, modifying arguments or return values. Several other hook methods are also provided for Wire derived classes that are hooking into others.


Click any linked item for full usage details and examples. Hookable methods are indicated with the icon.

Show class?             Show args?        

Common

NameReturnSummary 
Wire::wire()
mixedGet an API variable, create an API variable, or inject dependencies. 

Notices

NameReturnSummary 
Wire::error($text)
$thisRecord an non-fatal error message in the system-wide notices. 
Wire::errors()
Notices array stringReturn or manage errors recorded by just this object or all Wire objects 
Wire::log()
WireLogLog a message for this class
Wire::message($text)
$thisRecord an informational or “success” message in the system-wide notices. 
Wire::messages()
Notices array stringReturn or manage messages recorded by just this object or all Wire objects 
Wire::warning($text)
$thisRecord a warning error message in the system-wide notices. 
Wire::warnings()
Notices array stringReturn or manage warnings recorded by just this object or all Wire objects 

Identification

NameReturnSummary 
Wire::className()
stringReturn this object’s class name 
Wire::getInstanceNum()
intGet this Wire object’s instance number 

For hooks

These methods are only useful for hooking and should not be called directly.

NameReturnSummary 
Wire::callUnknown(string $method, array $arguments)
null mixedIf method call resulted in no handler, this hookable method is called.
Wire::changed(string $what)
(nothing)Hookable method that is called whenever a property has changed while change tracking is enabled.
Wire::trackException($e)
$thisHookable method called when an Exception occurs

Hooks

Methods for managing hooks for an object instance or class.

Changes

Methods to support tracking and retrieval of changes made to the object.

NameReturnSummary 
Wire::getChanges()
arrayReturn an array of properties that have changed while change tracking was on. 
Wire::isChanged()
boolDoes the object have changes, or has the given property changed? 
Wire::resetTrackChanges()
$thisClears out any tracked changes and turns change tracking ON or OFF 
Wire::setTrackChanges()
$thisTurn change tracking ON or OFF 
Wire::trackChange(string $what)
$thisTrack a change to a property in this object 
Wire::trackChanges()
int boolReturns true or 1 if change tracking is on, or false or 0 if it is not, or mode bitmask (int) if requested. 
Wire::trackChangesOn const2For setTrackChanges() method flags: track names only (default). 
Wire::trackChangesValues const4For setTrackChanges() method flags: track names and values. 
Wire::untrackChange(string $what)
$thisUntrack a change to a property in this object 

Api helpers

Shortcuts to ProcessWire API variables. Access without any arguments returns the API variable. Some support arguments as shortcuts to methods in the API variable.

NameReturnSummary 
Wire::cache()
WireCache string array PageArray nullAccess the $cache API variable as a function.
Wire::config()
Config mixedAccess the $config API variable as a function.
Wire::database()
WireDatabasePDOAccess the $database API variable as a function.
Wire::datetime()
WireDateTime string intAccess the $datetime API variable as a function.
Wire::fields()
Field Fields nullAccess the $fields API variable as a function.
Wire::files()
WireFileToolsAccess the $files API variable as a function.
Wire::input()
WireInput WireInputData array string int nullAccess the $input API variable as a function.
Wire::inputCookie()
WireInputData string int array nullAccess the $input->cookie() API variable as a function.
Wire::inputGet()
WireInputData string int array nullAccess the $input->get() API variable as a function.
Wire::inputPost()
WireInputData string int array nullAccess the $input->post() API variable as a function.
Wire::languages()
Languages Language NullPage nullAccess the $languages API variable as a function.
Wire::modules()
Modules Module ConfigurableModule nullAccess the $modules API variable as a function.
Wire::page()
Page MixedAccess the $page API variable as a function.
Wire::pages()
Pages PageArray Page NullPageAccess the $pages API variable as a function.
Wire::permissions()
Permissions Permission PageArray null NullPageAccess the $permissions API variable as a function.
Wire::roles()
Roles Role PageArray null NullPageAccess the $roles API variable as a function.
Wire::sanitizer()
Sanitizer string int array null mixedAccess the $sanitizer API variable as a function.
Wire::session()
Session mixedAccess the $session API variable as a function.
Wire::templates()
Templates Template nullAccess the $templates API variable as a function.
Wire::user()
User mixedAccess the $user API variable as a function.
Wire::users()
Users PageArray User mixedAccess the $users API variable as a function.

API reference based on ProcessWire core version 3.0.137

Twitter updates

  • New post: This week we’ll take a look at a new version of FormBuilder that's on the way (with a screencast), as well as the latest version of the core: ProcessWire 3.0.140— More
    6 September 2019
  • We added WebP image support this year and many have been adopting it in existing projects. We look at a process used for migrating existing websites to WebP images— from preliminary considerations to implementation & testing, w/lots of tips & tricks too: More
    16 August 2019
  • Core version 3.0.137 on the dev branch adds the ability to hook multiple methods at once, in a single call. This post details how it works and provides a useful example of how you might put it to use in your development environment— More
    2 August 2019

Latest news

  • ProcessWire Weekly #279
    This week in the 279th issue of ProcessWire Weekly we're going to introduce some of the latest third party modules out there, and highlight a brand new site of the week. Read on!
    Weekly.pw / 14 September 2019
  • ProcessWire 3.0.140 and FormBuilder v40
    This week we’ll take a look at a new version of FormBuilder that's on the way (with a screencast), as well as the latest version of the core: ProcessWire 3.0.140.
    Blog / 6 September 2019
  • Subscribe to weekly ProcessWire news

“Yesterday I sent the client a short documentation for their ProcessWire-powered website. Today all features already used with no questions. #cmsdoneright—Marc Hinse, Web designer/developer