Yii2架構打包成Phar包出錯的經曆

來源:互聯網
上載者:User
Yii2架構打包成Phar包報錯的經曆

以yii2為例

打包檔案過程比較簡單,但打包好以後,一直報錯:

PHP Fatal error: Uncaught yii\base\InvalidParamException: The directory does not exist: phar:///Users/jimmy/PHP/Library/yii2-advanced/yii2.phar/console in phar:///Users/jimmy/PHP/Library/yii2-advanced/yii2.phar/base/Module.php:224

一開始一直以為是打包出了問題有檔案沒有被打包進去,換了各種姿勢去打包,還是報各種錯。

最後沒辦法的情況下,去看了報錯的這個檔案,發現用了realpath來判斷路徑是否存在,注釋掉後,基本正常。這是php一個bug。

/** * Sets the root directory of the module. * This method can only be invoked at the beginning of the constructor. * @param string $path the root directory of the module. This can be either a directory name or a path alias. * @throws InvalidParamException if the directory does not exist. */public function setBasePath($path){    $path = Yii::getAlias($path);    $p = $path;//realpath();    if ($p !== false && is_dir($p)) {        $this->_basePath = $p;    } else {        throw new InvalidParamException("The directory does not exist: $path");    }}

http://git.oschina.net/web3d/codes/zyhsoev0b3i9u5njgaf42

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.