symfony - 自己編譯的php5.4.6無法運行composer
怪我咯
怪我咯 2017-05-16 16:45:33
0
2
600

當我嘗試使用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 參數,問題就解決了,具體為什麼我不太清楚。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板