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 Path service is globally accessible in Craft via Craft::$app->path.

View source

Public Properties

assetSourcesPath

Type
string
Access
Read-only

View source

assetThumbsPath

Type
string
Access
Read-only

View source

assetsIconsPath

Type
string
Access
Read-only

View source

assetsPath

Type
string
Access
Read-only

View source

cachePath

Type
string
Access
Read-only

View source

compiledClassesPath

Type
string
Access
Read-only

View source

compiledTemplatesPath

Type
string
Access
Read-only

View source

composerBackupsPath

Type
string
Access
Read-only

View source

configBackupPath

Type
string
Access
Read-only

View source

configPath

Type
string
Access
Read-only

View source

cpTemplatesPath

Type
string
Access
Read-only

View source

cpTranslationsPath

Type
string
Access
Read-only

View source

dbBackupPath

Type
string
Access
Read-only

View source

imageEditorSourcesPath

Type
string
Access
Read-only

View source

licenseKeyPath

Type
string
Access
Read-only

View source

logPath

Type
string
Access
Read-only

View source

pluginIconsPath

Type
string
Access
Read-only

View source

projectConfigFilePath

Type
string
Access
Read-only

View source

rebrandPath

Type
string
Access
Read-only

View source

runtimePath

Type
string
Access
Read-only

View source

sessionPath

Type
string
Access
Read-only

View source

siteTemplatesPath

Type
string
Access
Read-only

View source

siteTranslationsPath

Type
string
Access
Read-only

View source

storagePath

Type
string
Access
Read-only

View source

tempAssetUploadsPath

Type
string
Access
Read-only

View source

tempPath

Type
string
Access
Read-only

View source

vendorPath

Type
string
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 an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to 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.
getAssetThumbsPath()Returns the path to the storage/runtime/assets/thumbs/ 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/configs/ 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.
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.yaml.
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.
getTempAssetUploadsPath()Returns the path to the storage/runtime/assets/tempuploads/ directory.
getTempPath()Returns the path to the storage/runtime/temp/ 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.
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

getAssetThumbsPath()

Returns the path to the storage/runtime/assets/thumbs/ 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/configs/ 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

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

View source

Returns

string

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

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

getVendorPath()

Returns the path to the vendor/ directory.

View source

Returns

string

Throws