Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I retrieve Composer via Ant?

I'm trying to get make my Ant script retrieve Composer for me. Composer is a dependancy manager for PHP. According to the doc one needs to run this command: "curl -s https://getcomposer.org/installer | php" which will download Composer.phar into the directory I'm in. This works as intended when running from a terminal.

How do I setup the Ant build file for this? So far I've got this segment for the "composerget" target, but it's doesn't save the file, only output it in my command 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 greatly appeciated.

like image 390
Coreus Avatar asked Feb 07 '13 12:02

Coreus


People also ask

How do I access the composer?

It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things. Now run php composer.phar in order to run Composer. Now run php bin/composer in order to run Composer.

Where is my composer phar file?

The downloaded composer. phar file will be saved under the project root folder. Then, choose one of the configured local PHP interpreters from the PHP interpreter list.


1 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>

Should do the trick.

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

Attribution.

like image 81
Mez Avatar answered Sep 19 '22 00:09

Mez