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

WBOY
Libérer: 2016-06-13 12:28:24
original
1016 Les gens l'ont consulté

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。

<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>
Copier après la connexion

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

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!