Maintains lists of file paths or URLs, primarily used by the ProcessWire $config->paths and $urls API variables.
The Paths class is used by
$config->paths refers to server disk paths
$config->urls refers to web server URLs. All of the same properties are present on both, though several properties
are only useful on one or the other (as outlined below). You can access a path or URL like this:
$path = $config->paths->templates; // i.e. /path/to/htdocs/site/templates/ $url = $config->urls->templates; // i.e. /site/templates/
$url = $urls->templates; // i.e. /site/templates/
$httpUrl = $config->urls->httpTemplates; // i.e. https://domain.com/site/templates/ $httpUrl = $urls->httpTemplates; // same as above
You may optionally add your own properties as well. If you add a path/url without a leading slash “/” it is assumed to
be relative to the
root property. If it has a leading slash, then it is absolute.
// add new urls properties $urls->set('css', 'site/templates/css/'); // relative to site root $urls->set('uikit', '/uikit/dist/'); // absolute // get properties that were set echo $urls->get('css'); // i.e. /site/templates/css/ echo $urls->get('uikit'); // i.e. /uikit/dist/ echo $urls->get('httpCss'); // i.e. https://domain.com/site/templates/css/ echo $urls->get('httpUikit'); // i.e. https://domain.com/uikit/dist/ echo $urls->httpUikit; // same as above (using get method call is optional for any of these)
Do not set
http properties directly, as they are dynamically generated from
urls properties at runtime upon request.
In the examples on this page, you can replace the
$urls variable with
$config->paths if you need to get the server path
instead of a URL. As indicated earlier,
$urls can aso be accessed at the more verbose
$config->urls if you prefer.
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the
Paths class also inherits all the methods and properties of: WireData and Wire.
Additional methods and properties
In addition to the methods and properties above, Paths also inherits the methods and properties of these classes:
API reference based on ProcessWire core version 3.0.148