How to get a composer through Ant?

I am trying to get my Ant script to extract Composer for me. Composer is a dependency manager for PHP. According to the document , the following command is required: "curl -s https://getcomposer.org/installer | php", which will load Composer.phar into the directory in which I am located. This works as expected when working with the terminal.

How do I configure the Ant build file for this? So far I have this segment for the purpose of "composer", but it does not save the file, but displays it only in my shell:

.... <target name="composerget" description="Composer update dependencies"> <exec executable="curl"> <arg line="-s" /> <arg line="https://getcomposer.org/installer"/> <arg line="| php" /> </exec> </target> .... 

Any help is pretty much called out.

+7
source share
2 answers
 <target name="composerget" description="Composer update dependencies"> <exec executable="/bin/bash"> <arg value="-c" /> <arg value="curl -s https://getcomposer.org/installer | php" /> </exec> </target> 

Gotta do the trick.

The pipe (|) can only be used in a shell script. You pass this as an argument to the curl. So you need to execute a shell script - which you can do with bash -c and pass the command as a shell statement.

Attribution.

+8
source

This will download the Composer installer, verify its signature and launch the installer:

  <target name="composer" description="Install composer"> <exec executable="wget"> <arg value="-O" /> <arg value="composer-setup.sig" /> <arg value="https://composer.imtqy.com/installer.sig" /> </exec> <exec executable="wget"> <arg value="-O" /> <arg value="composer-setup.php" /> <arg value="https://getcomposer.org/installer" /> </exec> <exec executable="bash"> <arg value="-c" /> <arg value="awk '{print $$0 &quot; composer-setup.php&quot;}' composer-setup.sig | sha384sum --check" /> </exec> <exec executable="php"> <arg value="composer-setup.php" /> </exec> <exec executable="rm"> <arg value="composer-setup.php" /> </exec> <exec executable="rm"> <arg value="composer-setup.sig" /> </exec> <exec executable="mv"> <arg value="composer.phar" /> <arg value="composer" /> </exec> </target> 

If you are using GNU Make, this is the equivalent:

 all: vendor vendor: composer composer.json composer.lock ./composer install composer: wget -O composer-setup.sig https://composer.imtqy.com/installer.sig wget -O composer-setup.php https://getcomposer.org/installer awk '{print $$0 " composer-setup.php"}' composer-setup.sig | sha384sum --check php composer-setup.php --quiet rm composer-setup.* mv composer.phar composer 
0
source

All Articles