Home >Backend Development >PHP Tutorial >Experience of error reporting when packaging Yii2 framework into Phar package
Take yii2 as an example
The process of packaging files is relatively simple, but after packaging, an error keeps reporting:
PHP Fatal error: Uncaught yiibaseInvalidParamException: 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
At first I thought there was a problem with the packaging and there were files It was not packed in. I changed various positions to pack it, but still reported various errors.
In the end, when I had no choice, I looked at the file that reported the error and found that realpath was used to determine whether the path existed. After commenting it out, it was basically normal. This is a bug in php.
<code>/** * 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"); } }</code>
http://git.oschina.net/web3d/codes/zyhsoev0b3i9u5njgaf42
The above introduces the experience of error reporting when the Yii2 framework is packaged into a Phar package, including relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.