Configuration paths and URLs (Paths class)

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 and $config->urls. The $config->paths refers to server disk paths while $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/

The $config->urls property can also be accessed more directly via the $urls API variable (in PW 3.x+):

$url = $urls->templates; // i.e. /site/templates/

For $config->urls (or $urls), if you prepend http to any of the property names (making it camelCase) it will return the full http/https URL rather then the relative URL:

$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.

Show $var?             Show args?        

Common

NameReturnSummary 
$urls->assets string Site-specific assets: /site/assets/ 
$urls->core string ProcessWire core files: /wire/core/ 
$urls->files string Site-specific files: /site/assets/files/ 
$urls->modules string Core modules: /wire/modules/ 
$urls->root string Site root: / (or subdirectory if site not at domain root) 
$urls->site string ProcessWire site files /site/ 
$urls->siteModules string Site-specific modules: /site/modules/ 
$urls->templates string Site templates: /site/templates/ 

Methods

NameReturnSummary 
$urls->get($key)
mixed null stringReturn the requested path or URL (functionally the same as direct access) 
$urls->set(string $key, mixed $value)
Paths WireDataSet a new path/URL location 

Paths only

These properties are only useful when accessed from $config->paths as they are not HTTP accessible as URLs.

NameReturnSummary 
$urls->cache string Site-specific cache: /site/assets/cache/  
$urls->classes string Site-specific class files: /site/classes/  
$urls->fieldTemplates string Site field templates /site/templates/fields/  
$urls->logs string Site-specific logs: /site/assets/logs/  
$urls->sessions string Session files: /site/assets/sessions/  
$urls->tmp string Temporary files: /site/assets/tmp/  

Urls only

These properties apply only to the $urls or $config->urls. Do not use them with $config->paths.

NameReturnSummary 
$urls->admin string Admin URL  
$urls->httpAssets string Full http/https URL to site assets (i.e. https://domain.com/site/assets/).  
$urls->httpFiles string Full http/https URL to site assets files (i.e. https://domain.com/site/assets/files/).  
$urls->httpModules string Full http/https URL to core (wire) modules.  
$urls->httpNext string Full http/https URL to next pagination of current page (when applicable).  
$urls->httpPrev string Full http/https URL to prev pagination of current page (when applicable).  
$urls->httpRoot string Full http/https URL to site root (i.e. https://domain.com/).  
$urls->httpSiteModules string Full http/https URL to site modules.  
$urls->httpTemplates string Full http/https URL to site templates (i.e. https://domain.com/site/templates/).  
$urls->next string null URL to next pagination of current page, when applicable (populated by MarkupPagerNav, after render)  
$urls->prev string null URL to previous pagination of current page, when applicable (populated by MarkupPagerNav, after render)  

Pagination

These properties apply only to the $urls or $config->urls and only when pagination is active for the current request.

NameReturnSummary 
$urls->httpNext string Full http/https URL to next pagination of current page (when applicable).  
$urls->httpPrev string Full http/https URL to prev pagination of current page (when applicable).  
$urls->next string null URL to next pagination of current page, when applicable (populated by MarkupPagerNav, after render)  
$urls->prev string null URL to previous pagination of current page, when applicable (populated by MarkupPagerNav, after render)  

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.163

Twitter updates

  • Quick weekly update covering this week's commits for the upcoming 3.0.167 ProcessWire core version— More
    18 September 2020
  • This week ProcessWire version 3.0.166 is released on the dev branch. In this post we’ll cover all that’s new relative to the previous version, 3.0.165. Plus we’ll check out the latest new versions of ProCache and FormBuilder— More
    11 September 2020
  • Weekly update – 28 August 2020 – New secure files option defined per-template: More
    28 August 2020

Latest news

  • ProcessWire Weekly #332
    In the 332nd issue of ProcessWire Weekly we'll cover the latest core updates, introduce some new and updated ProcessWire resources, and more. Read on!
    Weekly.pw / 19 September 2020
  • ProcessWire 3.0.166 core updates and more
    This week ProcessWire version 3.0.166 is released on the dev branch. In this post we’ll cover all that’s new relative to the previous version, 3.0.165. Plus we’ll check out the latest new versions of ProCache and FormBuilder.
    Blog / 11 September 2020
  • Subscribe to weekly ProcessWire news

“Indeed, if ProcessWire can be considered as a CMS in its own right, it also offers all the advantages of a CMF (Content Management Framework). Unlike other solutions, the programmer is not forced to follow the proposed model and can integrate his/her ways of doing things.” —Guy Verville, Spiria Digital Inc.