ProcessWire‘s wire()
function gives you access to pretty its entire API. But if you use your own namespace then wire()
will not be available since it is in the ProcessWire
namespace (although it is available in the global namesapce once you are in a template).
Assuming you are writing your own namespace’d classes for your application/website there are serveral ways to make wire()
available.
- Add
use function ProcessWire\wire
after your namespace declaration; this will aliaswire()
and make it available in that file/class - Call
\ProcessWire\wire()
; although more verbose this will work from anywhere - Use the
ProcessWire
namespace for your classes - Add a
wire()
function in the global namespace that accesses\ProcessWire\wire()
(see function below):
A global wrapper for wire()
:
function wire($key, …) {
return \ProcessWire\wire($key, …);
}
Tim Bennett is a web designer and developer. He has a First Class Honours degree in Computing from
Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.