以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
一开始一直以为是打包出了问题有文件没有被打包进去,换了各种姿势去打包,还是报各种错。
CRMEB打通版是一款全开源支持免费商用的PHP 多语言商城系统;CRMEB技术团队历经6年时间匠心之作!系统采用前后端分离技术,基于TP6+Uni-app框架开发;客户移动端采用uni-app开发,管理后台前端使用iviewUI开发。系统支持微信公众号端、微信小程序端、H5端、PC端多端账号同步,可快速打包生成APP;赋能开发者,减少重复造轮子;系统支持自动检查安装环境一键安装部署,使用简单方便
最后没办法的情况下,去看了报错的这个文件,发现用了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
以上就介绍了Yii2框架打包成Phar包报错的经历,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。









