在非标准位置使用带有php的composer

时间:2016-01-06 20:24:54

标签: php composer-php

我试图在我的NAS上使用作曲家(一个很好的旧D-Link DNS-323运行非常好的fonz有趣插头0.7)。

我在/ffp/bin/php安装了我的php。

使用以下命令安装composer时

 php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/ffp/sbin --filename=composer

但是当我做一个简单的less /ffp/sbin/composer时,我有以下shebang集:

#!/usr/bin/env php
<?php
/*
 * This file is part of Composer.
 *

不幸的是,我的NAS上没有/usr/bin/env文件夹存在于我的机器上...... 那么,我怎样才能让作曲家引用正确的php可执行文件?

此外,我尝试将声明更改为使用#!/ffp/bin/php,但是这样做时,任何作曲家运行都会回应以下结果:

PHP Warning:  PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/gd.so' - File not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/gd.so' - File not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/sqlite.so' - File not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/sqlite.so' - File not found in Unknown on line 0
PHP Fatal error:  Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23
Stack trace:
#0 /mnt/HD_a2/ffp/sbin/composer(23): Phar::mapPhar('composer.phar')
#1 {main}
  thrown in /mnt/HD_a2/ffp/sbin/composer on line 23
Fatal error: Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23
Stack trace:
#0 /mnt/HD_a2/ffp/sbin/composer(23): Phar::mapPhar('composer.phar')
#1 {main}
  thrown in /mnt/HD_a2/ffp/sbin/composer on line 23

特别重要的是行

PHP Fatal error:  Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23

我该如何解决?换句话说,如何在我的NAS上安装有效的php + composer?

1 个答案:

答案 0 :(得分:0)

  

那么,我怎样才能让作曲家引用正确的php可执行文件?

一个非常简单的解决方案是创建一个shell脚本:

#!/bin/sh
/ffp/bin/php -n /ffp/sbin/composer "$@"

将其设为可执行文件,将其命名为composer,将其放在/ffp/sbin之前的路径中(或将/ffp/sbin/composer重命名为composer.phar并更新上述脚本。)

-n标志告诉PHP不使用php.ini。当从php.ini加载许多扩展时,这非常有用;不加载它们会使composer运行得更快。为提高速度,xdebug composer {{#if params.link}} {{#link-to params.link}} {{fa-icon icon=params.icon}} {{#if params.label.left}}<span class="label label-left">{{params.label.left}}</span><i class="triangle triangle-right"></i>{{/if}} {{#if params.text}}<span class="text">{{params.text}}</span>{{/if}} {{#if params.label.right}}<i class="triangle triangle-left"></i><span class="label label-right">{{params.label.right}}</span>{{/if}}{{/if}} {{/link-to}} {{else}} <button {{action params.action}}> {{fa-icon icon=params.icon}} {{#if params.label.left}}<span class="label label-left">{{params.label.left}}</span><i class="triangle triangle-right"></i>{{/if}} {{#if params.text}}<span class="text">{{params.text}}</span>{{/if}} {{#if params.label.right}}<i class="triangle triangle-left"></i><span class="label label-right">{{params.label.right}}</span>{{/if}}{{/if}} </button> {{/if}} 2.2.0