Skip to content

Path ​

Type
Class
Namespace
craft\services
Inherits
craft\services\Path » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Since
3.0.0

The Path service provides APIs for getting server paths that are used by Craft.

An instance of the service is available via Craft::$app->path.

View source

Public Properties ​

PropertyDescription
assetSourcesPathstring
assetsIconsPathstring
assetsPathstring
behaviorsyii\base\Behavior – List of behaviors attached to this component.
cachePathstring
compiledClassesPathstring
compiledTemplatesPathstring
composerBackupsPathstring
configBackupPathstring
configDeltaPathstring
configPathstring
cpTemplatesPathstring
cpTranslationsPathstring
dbBackupPathstring
imageEditorSourcesPathstring
imageTransformsPathstring
licenseKeyPathstring
logPathstring
pluginIconsPathstring
projectConfigFilePathstring
projectConfigPathstring
rebrandPathstring
runtimePathstring
sessionPathstring
siteTemplatesPathstring
siteTranslationsPathstring
storagePathstring
systemPathsstring[]
tempAssetUploadsPathstring
tempPathstring
testsPathstring
vendorPathstring

assetSourcesPath ​

Type
string
Default value
null
Access
Read-only

View source

assetsIconsPath ​

Type
string
Default value
null
Access
Read-only

View source

assetsPath ​

Type
string
Default value
null
Access
Read-only

View source

cachePath ​

Type
string
Default value
null
Access
Read-only

View source

compiledClassesPath ​

Type
string
Default value
null
Access
Read-only

View source

compiledTemplatesPath ​

Type
string
Default value
null
Access
Read-only

View source

composerBackupsPath ​

Type
string
Default value
null
Access
Read-only
Since
3.0.38

View source

configBackupPath ​

Type
string
Default value
null
Access
Read-only
Since
3.1.0

View source

configDeltaPath ​

Type
string
Default value
null
Access
Read-only
Since
3.4.0

View source

configPath ​

Type
string
Default value
null
Access
Read-only

View source

cpTemplatesPath ​

Type
string
Default value
null
Access
Read-only

View source

cpTranslationsPath ​

Type
string
Default value
null
Access
Read-only

View source

dbBackupPath ​

Type
string
Default value
null
Access
Read-only

View source

imageEditorSourcesPath ​

Type
string
Default value
null
Access
Read-only

View source

imageTransformsPath ​

Type
string
Default value
null
Access
Read-only
Since
4.4.0

View source

licenseKeyPath ​

Type
string
Default value
null
Access
Read-only

View source

logPath ​

Type
string
Default value
null
Access
Read-only

View source

pluginIconsPath ​

Type
string
Default value
null
Access
Read-only

View source

projectConfigFilePath ​

Type
string
Default value
null
Access
Read-only
Since
3.1.2

View source

projectConfigPath ​

Type
string
Default value
null
Access
Read-only
Since
3.5.0

View source

rebrandPath ​

Type
string
Default value
null
Access
Read-only

View source

runtimePath ​

Type
string
Default value
null
Access
Read-only

View source

sessionPath ​

Type
string
Default value
null
Access
Read-only

View source

siteTemplatesPath ​

Type
string
Default value
null
Access
Read-only

View source

siteTranslationsPath ​

Type
string
Default value
null
Access
Read-only

View source

storagePath ​

Type
string
Default value
null
Access
Read-only

View source

systemPaths ​

Type
string[]
Default value
null
Access
Read-only
Since
3.7.17

View source

tempAssetUploadsPath ​

Type
string
Default value
null
Access
Read-only

View source

tempPath ​

Type
string
Default value
null
Access
Read-only

View source

testsPath ​

Type
string
Default value
null
Access
Read-only
Since
3.4.29

View source

vendorPath ​

Type
string
Default value
null
Access
Read-only

View source

Public Methods ​

MethodDescription
__call()Calls the named method which is not a class method.
__clone()This method is called after the object is created by cloning an existing one.
__construct()Constructor.
__get()Returns the value of a component property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets the value of a component property.
__unset()Sets a component property to be null.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
behaviors()Returns a list of behaviors that this component should behave as.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
getAssetSourcesPath()Returns the path to the storage/runtime/assets/sources/ directory.
getAssetsIconsPath()Returns the path to the storage/runtime/assets/icons/ directory.
getAssetsPath()Returns the path to the storage/runtime/assets/ directory.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getCachePath()Returns the path to the file cache directory.
getCompiledClassesPath()Returns the path to the storage/runtime/compiled_classes/ directory.
getCompiledTemplatesPath()Returns the path to the storage/runtime/compiled_templates/ directory.
getComposerBackupsPath()Returns the path to the storage/composer-backups/ directory.
getConfigBackupPath()Returns the path to the storage/config-backups/ directory.
getConfigDeltaPath()Returns the path to the storage/config-deltas/ directory.
getConfigPath()Returns the path to the config/ directory.
getCpTemplatesPath()Returns the path to the app/templates/ directory.
getCpTranslationsPath()Returns the path to the app/translations/ directory.
getDbBackupPath()Returns the path to the storage/backups/ directory.
getImageEditorSourcesPath()Returns the path to the storage/runtime/assets/imageeditor/ folder.
getImageTransformsPath()Returns the path to the storage/runtime/assets/imagetransforms/ directory.
getLicenseKeyPath()Returns the path to the license key file.
getLogPath()Returns the path to the storage/logs/ directory.
getPluginIconsPath()Returns the path to the storage/runtime/pluginicons/ directory.
getProjectConfigFilePath()Returns the path to config/project/project.yaml.
getProjectConfigPath()Returns the path to config/project/ directory.
getRebrandPath()Returns the path to the storage/rebrand/ directory.
getRuntimePath()Returns the path to the storage/runtime/ directory.
getSessionPath()Returns the path to the storage/runtime/sessions/ directory.
getSiteTemplatesPath()Returns the path to the templates/ directory.
getSiteTranslationsPath()Returns the path to the translations/ directory.
getStoragePath()Returns the path to the storage/ directory.
getSystemPaths()Returns an array of all system directories.
getTempAssetUploadsPath()Returns the path to the storage/runtime/assets/tempuploads/ directory.
getTempPath()Returns the path to the storage/runtime/temp/ directory.
getTestsPath()Returns the path to the tests/ directory.
getVendorPath()Returns the path to the vendor/ directory.
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined for this component.
init()Initializes the object.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
trigger()Triggers an event.

getAssetSourcesPath() ​

Returns the path to the storage/runtime/assets/sources/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getAssetsIconsPath() ​

Returns the path to the storage/runtime/assets/icons/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getAssetsPath() ​

Returns the path to the storage/runtime/assets/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getCachePath() ​

Returns the path to the file cache directory.

This will be located at storage/runtime/cache/ by default, but that can be overridden with the 'cachePath' config setting in config/filecache.php.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getCompiledClassesPath() ​

Returns the path to the storage/runtime/compiled_classes/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getCompiledTemplatesPath() ​

Returns the path to the storage/runtime/compiled_templates/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getComposerBackupsPath() ​

Since
3.0.38

Returns the path to the storage/composer-backups/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

Throws ​

getConfigBackupPath() ​

Since
3.1.0

Returns the path to the storage/config-backups/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

Throws ​

getConfigDeltaPath() ​

Since
3.4.0

Returns the path to the storage/config-deltas/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

Throws ​

getConfigPath() ​

Returns the path to the config/ directory.

View source

Returns ​

string

Throws ​

getCpTemplatesPath() ​

Returns the path to the app/templates/ directory.

View source

Returns ​

string

getCpTranslationsPath() ​

Returns the path to the app/translations/ directory.

View source

Returns ​

string

getDbBackupPath() ​

Returns the path to the storage/backups/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

Throws ​

getImageEditorSourcesPath() ​

Returns the path to the storage/runtime/assets/imageeditor/ folder.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getImageTransformsPath() ​

Since
4.4.0

Returns the path to the storage/runtime/assets/imagetransforms/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getLicenseKeyPath() ​

Returns the path to the license key file.

View source

Returns ​

string

getLogPath() ​

Returns the path to the storage/logs/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

Throws ​

getPluginIconsPath() ​

Returns the path to the storage/runtime/pluginicons/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getProjectConfigFilePath() ​

Since
3.1.2

Returns the path to config/project/project.yaml.

View source

Returns ​

string

getProjectConfigPath() ​

Since
3.5.0

Returns the path to config/project/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

Throws ​

getRebrandPath() ​

Returns the path to the storage/rebrand/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

Throws ​

getRuntimePath() ​

Returns the path to the storage/runtime/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

Throws ​

getSessionPath() ​

Returns the path to the storage/runtime/sessions/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getSiteTemplatesPath() ​

Returns the path to the templates/ directory.

View source

Returns ​

string

Throws ​

getSiteTranslationsPath() ​

Returns the path to the translations/ directory.

View source

Returns ​

string

Throws ​

getStoragePath() ​

Returns the path to the storage/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

Throws ​

getSystemPaths() ​

Since
3.7.17

Returns an array of all system directories.

View source

Returns ​

string[]

getTempAssetUploadsPath() ​

Returns the path to the storage/runtime/assets/tempuploads/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getTempPath() ​

Returns the path to the storage/runtime/temp/ directory.

View source

Arguments ​

  • $create (boolean) – Whether the directory should be created if it doesn't exist

Returns ​

string

getTestsPath() ​

Since
3.4.29

Returns the path to the tests/ directory.

View source

Returns ​

string

Throws ​

getVendorPath() ​

Returns the path to the vendor/ directory.

View source

Returns ​

string

Throws ​