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
.
Public Properties ​
assetSourcesPath
​
- Type
- string
- Default value
null
- Access
- Read-only
assetThumbsPath
​
- Type
- string
- Default value
null
- Access
- Read-only
assetsIconsPath
​
- Type
- string
- Default value
null
- Access
- Read-only
assetsPath
​
- Type
- string
- Default value
null
- Access
- Read-only
cachePath
​
- Type
- string
- Default value
null
- Access
- Read-only
compiledClassesPath
​
- Type
- string
- Default value
null
- Access
- Read-only
compiledTemplatesPath
​
- Type
- string
- Default value
null
- Access
- Read-only
composerBackupsPath
​
- Type
- string
- Default value
null
- Access
- Read-only
- Since
- 3.0.38
configBackupPath
​
- Type
- string
- Default value
null
- Access
- Read-only
- Since
- 3.1.0
configDeltaPath
​
- Type
- string
- Default value
null
- Access
- Read-only
- Since
- 3.4.0
configPath
​
- Type
- string
- Default value
null
- Access
- Read-only
cpTemplatesPath
​
- Type
- string
- Default value
null
- Access
- Read-only
cpTranslationsPath
​
- Type
- string
- Default value
null
- Access
- Read-only
dbBackupPath
​
- Type
- string
- Default value
null
- Access
- Read-only
imageEditorSourcesPath
​
- Type
- string
- Default value
null
- Access
- Read-only
licenseKeyPath
​
- Type
- string
- Default value
null
- Access
- Read-only
logPath
​
- Type
- string
- Default value
null
- Access
- Read-only
pluginIconsPath
​
- Type
- string
- Default value
null
- Access
- Read-only
projectConfigFilePath
​
- Type
- string
- Default value
null
- Access
- Read-only
- Since
- 3.1.2
projectConfigPath
​
- Type
- string
- Default value
null
- Access
- Read-only
- Since
- 3.5.0
rebrandPath
​
- Type
- string
- Default value
null
- Access
- Read-only
runtimePath
​
- Type
- string
- Default value
null
- Access
- Read-only
sessionPath
​
- Type
- string
- Default value
null
- Access
- Read-only
siteTemplatesPath
​
- Type
- string
- Default value
null
- Access
- Read-only
siteTranslationsPath
​
- Type
- string
- Default value
null
- Access
- Read-only
storagePath
​
- Type
- string
- Default value
null
- Access
- Read-only
systemPaths
​
- Type
- string[]
- Default value
null
- Access
- Read-only
- Since
- 3.7.17
tempAssetUploadsPath
​
- Type
- string
- Default value
null
- Access
- Read-only
tempPath
​
- Type
- string
- Default value
null
- Access
- Read-only
testsPath
​
- Type
- string
- Default value
null
- Access
- Read-only
- Since
- 3.4.29
vendorPath
​
- Type
- string
- Default value
null
- Access
- Read-only
Public Methods ​
Method | Description |
---|---|
__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. |
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/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. |
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.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getAssetThumbsPath()
​
Returns the path to the storage/runtime/assets/thumbs/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getAssetsIconsPath()
​
Returns the path to the storage/runtime/assets/icons/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getAssetsPath()
​
Returns the path to the storage/runtime/assets/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
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
.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getCompiledClassesPath()
​
Returns the path to the storage/runtime/compiled_classes/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getCompiledTemplatesPath()
​
Returns the path to the storage/runtime/compiled_templates/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getComposerBackupsPath()
​
- Since
- 3.0.38
Returns the path to the storage/composer-backups/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
Throws ​
getConfigBackupPath()
​
- Since
- 3.1.0
Returns the path to the storage/config-backups/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
Throws ​
getConfigDeltaPath()
​
- Since
- 3.4.0
Returns the path to the storage/config-deltas/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
Throws ​
getConfigPath()
​
Returns the path to the config/
directory.
Returns ​
Throws ​
getCpTemplatesPath()
​
Returns the path to the app/templates/
directory.
Returns ​
getCpTranslationsPath()
​
Returns the path to the app/translations/
directory.
Returns ​
getDbBackupPath()
​
Returns the path to the storage/backups/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
Throws ​
getImageEditorSourcesPath()
​
Returns the path to the storage/runtime/assets/imageeditor/
folder.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getLicenseKeyPath()
​
Returns the path to the license key file.
Returns ​
getLogPath()
​
Returns the path to the storage/logs/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
Throws ​
getPluginIconsPath()
​
Returns the path to the storage/runtime/pluginicons/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getProjectConfigFilePath()
​
- Since
- 3.1.2
Returns the path to config/project/project.yaml
.
Returns ​
getProjectConfigPath()
​
- Since
- 3.5.0
Returns the path to config/project/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
Throws ​
getRebrandPath()
​
Returns the path to the storage/rebrand/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
Throws ​
getRuntimePath()
​
Returns the path to the storage/runtime/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
Throws ​
getSessionPath()
​
Returns the path to the storage/runtime/sessions/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getSiteTemplatesPath()
​
Returns the path to the templates/
directory.
Returns ​
Throws ​
getSiteTranslationsPath()
​
Returns the path to the translations/
directory.
Returns ​
Throws ​
getStoragePath()
​
Returns the path to the storage/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
Throws ​
getSystemPaths()
​
- Since
- 3.7.17
Returns an array of all system directories.
Returns ​
string[]
getTempAssetUploadsPath()
​
Returns the path to the storage/runtime/assets/tempuploads/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getTempPath()
​
Returns the path to the storage/runtime/temp/
directory.
Arguments ​
$create
(boolean) – Whether the directory should be created if it doesn't exist
Returns ​
getTestsPath()
​
- Since
- 3.4.29
Returns the path to the tests/
directory.
Returns ​
Throws ​
getVendorPath()
​
Returns the path to the vendor/
directory.