symfony - 自己编译的php5.4.6无法运行composer
怪我咯
怪我咯 2017-05-16 16:45:33
0
2
603

当我尝试使用curl和管道操作符直接传给php的去执行下载回来的install的时候报错了:

$ curl -s https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
The download is corrupt, retrying...
Downloading...
The download is corrupt, retrying...
Downloading...
The download is corrupt (internal corruption of phar "/work/doc/composer.phar" (truncated entry)), aborting.

然后我手动下载了install:

$ curl -s https://getcomposer.org/installer > composer

然后手动跟踪错误出在了哪里,然后跟踪到了一个try...catch语句:

......

try {
            // test the phar validity
            echo $file;
            $phar = new Phar($file);
            // free the variable to unlock the file
            unset($phar);
            break;
        } catch (Exception $e) {
            if (!$e instanceof UnexpectedValueException && !$e instanceof PharException) {
                throw $e;
            }
            unlink($file);
            if ($retries) {
                if (!$quiet) {
                   out('The download is corrupt, retrying...', 'error');
                }
            } else {
                out('The download is corrupt ('.$e->getMessage().'), aborting.', 'error');
                exit(1);
            }
        }
        
......

当 new Phar的时候出现了错误,于是我把这段代码拿出来,单独执行之后,php报了这样的错误:

$ cat test.php 
<?php

$file = '/work/doc/composer.phar';

$phar = new Phar($file);

unset($phar);

然后执行这个test.php,看到这样的错误:

$ php test.php 
PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'internal corruption of phar "/work/doc/composer.phar" (__HALT_COMPILER(); not found)' in /work/doc/test.php:5
Stack trace:
#0 /work/doc/test.php(5): Phar->__construct('/work/doc/compo...')
#1 {main}
  thrown in /work/doc/test.php on line 5

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'internal corruption of phar "/work/doc/composer.phar" (__HALT_COMPILER(); not found)' in /work/doc/test.php:5
Stack trace:
#0 /work/doc/test.php(5): Phar->__construct('/work/doc/compo...')
#1 {main}
  thrown in /work/doc/test.php on line 5

但是我已经有一份下载回来的脚本命名为 composer.phar,我把test.php命名为composer.phar也不行,下边是我的php的编译参数:

./configure --prefix=/opt/php/default --with-config-file-path=/opt/php/default/etc --with-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-libdir=lib64 --with-xmlrpc --enable-zip --enable-soap --with-pear --enable-pdo --with-pdo-mysql --with-gettext --enable-exif --enable-wddx --enable-calendar --enable-ftp --enable-dba --enable-sysvmsg --enable-sysvshm --enable-debug --enable-maintainer-zts --with-pcre-regex --enable-gd-jis-conv --with-apxs2=/opt/apache/default/bin/apxs
怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(2)
Peter_Zhu

跑下这个,

$ ./configure --help | grep curlwrappers

应该能看到这个选项是“试验性质”的,在http://us.php.net/manual/en/wrappers.... 里也找不到curl作为wrapper的正式说明。

况且,确实会导致fopen工作不正常。

巴扎黑

去掉编译时的 --with-curlwrappers 参数,问题就解决了,具体为什么我不太清楚。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板