ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

二十六、逐行阅读Yii2.0.43源码_Yii框架文件yii\base\Application.php(4)

2021-10-23 17:00:21  阅读:203  来源: 互联网

标签:vendor 路径 Yii 源码 vendorPath runtimePath php 目录 逐行


目录

一、属性

二、方法


 

一、属性

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方法,设置时区

标签:vendor,路径,Yii,源码,vendorPath,runtimePath,php,目录,逐行
来源: https://blog.csdn.net/mianhuatangVSyeyu/article/details/120922971

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有