Yii2框架打包成Phar包报错的经历

王朝学院·作者佚名  2016-08-28  
宽屏版  字体: 小 | 中 | 大 | 超大  

以yii2为例

打包文件过程比较简单,但打包好以后简单测试yii命令,一直报错:

phpFatal 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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有