Phing似乎无法使用tag /命令运行Composer。它似乎在当前目录中寻找composer.phar。因为它没有将composer.phar作为命令执行而是传递字符串' composer.phar'对于php二进制文件,它不能使用系统路径来查找composer.phar(除非我错了?)
如何在不明确告诉composer.phar的位置的情况下,让Phing正确运行编辑器?我不想这样做,因为这个构建脚本应该在任何安装了Composer和Phing的系统上运行。
我的项目有一个build.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<project name="my-awesome-app" default="build" basedir=".">
<target name="build">
<composer command="install"></composer>
</target>
</project>
我在OSX上通过MAMP Pro运行PHP,因此所有与PHP相关的脚本/二进制文件都在此目录中:
/Applications/MAMP/bin/php/php7.0.0/bin
# ls -al /Applications/MAMP/bin/php/php7.0.0/bin
total 120544
drwxrwxr-x 18 eric admin 612 25 Jul 10:14 .
drwxrwxr-x 8 eric admin 272 12 Jul 09:46 ..
-rwxr-xr-x 1 eric admin 1705349 14 Jul 19:40 composer
lrwxr-xr-x 1 eric admin 8 25 Jul 10:14 composer.phar -> composer
-rwxrwxr-x 1 eric admin 942 9 Dec 2015 pear
-rwxrwxr-x 1 eric admin 963 9 Dec 2015 peardev
-rwxrwxr-x 1 eric admin 879 9 Dec 2015 pecl
lrwxr-xr-x 1 eric admin 9 15 Dec 2015 phar -> phar.phar
-rwxrwxr-x 1 eric admin 14854 9 Dec 2015 phar.phar
-rwxr-xr-x 1 eric admin 797 25 Jul 09:12 phing
-rwxrwxr-x 1 eric admin 18944064 9 Dec 2015 php
-rwxrwxr-x 1 eric admin 18850440 9 Dec 2015 php-cgi
-rwxrwxr-x 1 eric admin 4126 9 Dec 2015 php-config
-rwxrwxr-x 1 eric admin 19149192 9 Dec 2015 phpdbg
-rwxrwxr-x 1 eric admin 4627 9 Dec 2015 phpize
lrwxr-xr-x 1 eric admin 12 13 Jul 23:29 phpunit -> phpunit.phar
-rwxr-xr-x@ 1 eric staff 2988429 13 Jul 23:28 phpunit.phar
运行phing的结果是:
# phing
Buildfile: /Users/eric/Development/php/phpstorm/my-awesome-app/build.xml
my-awesome-app > build:
[composer] executing /Applications/MAMP/bin/php/php7.0.0/bin/php composer.phar install
BUILD FAILED
/Users/eric/Development/php/phpstorm/my-awesome-app/build.xml:4:8: Composer binary not found, path is "composer.phar"
Total time: 0.0980 seconds
答案 0 :(得分:0)
我使用exec声明作为解决方法:
<exec command="composer install" />
这将使用系统路径查找composer脚本/ phar(我已将composer链接到composer.phar并使其可执行。
我不会将此答案标记为所选答案,因为我相信内置的composer命令应该能够工作而无需在构建文件中指定composer.phar的完整路径。
答案 1 :(得分:0)
如果您将一个空的php属性添加到composer标记中,只要composer在您的路径中,它就应该正确运行。
<composer php="" composer="composer" command="install" />