二十六、逐行阅读Yii2.0.43源码_Yii框架文件yii\base\Application.php(4)
2021/10/23 17:09:42
本文主要是介绍二十六、逐行阅读Yii2.0.43源码_Yii框架文件yii\base\Application.php(4),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
目录
一、属性
二、方法
一、属性
1. $_runtimePath 运行时文件的路径
2. $_vendorPath vendor目录路径
/** * 运行时文件的目录 */ private $_runtimePath; // vendor目录路径 private $_vendorPath;
二、方法
1. getRuntimePath方法,返回运行时目录路径
/** * 返回运行时文件的目录 */ public function getRuntimePath() { if ($this->_runtimePath === null) { $this->setRuntimePath($this->getBasePath() . DIRECTORY_SEPARATOR . 'runtime'); } return $this->_runtimePath; }
2. setRuntimePath方法,设置运行时路径
/** * 设置运行时文件的目录 */ public function setRuntimePath($path) { $this->_runtimePath = Yii::getAlias($path); Yii::setAlias('@runtime', $this->_runtimePath); }
3. getVendorPath方法,返回vendor路径
/** * 获取vendor目录路径 */ public function getVendorPath() { if ($this->_vendorPath === null) { $this->setVendorPath($this->getBasePath() . DIRECTORY_SEPARATOR . 'vendor'); } return $this->_vendorPath; }
4. setVendorPath方法,设置vendor路径
/** * 设置vendor目录 */ public function setVendorPath($path) { $this->_vendorPath = Yii::getAlias($path); Yii::setAlias('@vendor', $this->_vendorPath); Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower'); Yii::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm'); }
5. getTimeZone方法,返回时区
/** * 获取时区 */ public function getTimeZone() { return date_default_timezone_get(); }
6. setTimeZone方法,设置时区
/** * 时区设置 */ public function setTimeZone($value) { date_default_timezone_set($value); }
总结:
阅读了2个属性和6个方法:
- $_runtimePath 运行时文件的路径
- $_vendorPath vendor目录路径
- getRuntimePath方法,返回运行时目录路径
- setRuntimePath方法,设置运行时路径
- getVendorPath方法,返回vendor路径
- setVendorPath方法,设置vendor路径
- getTimeZone方法,返回时区
- setTimeZone方法,设置时区
这篇关于二十六、逐行阅读Yii2.0.43源码_Yii框架文件yii\base\Application.php(4)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29env: php: no such file or directory
- 2024-03-01php foreach break
- 2024-02-26Exception参数 php-icode9专业技术文章分享
- 2023-12-30PHP文件批量上传-icode9专业技术文章分享
- 2023-12-30thinkphp6 withJoin-icode9专业技术文章分享
- 2023-12-27MagicArray:像php一样,让Go业务代码不再卷!
- 2023-11-18centos7编译安装PHP教程。
- 2023-11-18centos7编译安装phpMyAdmin教程。
- 2023-10-13唱衰这么多年,PHP 仍然还是你大爷!
- 2023-07-25PHP8,性能更好,语法更好,类型安全更完善