0

I want to use that feature in order to set dependencies right via web interface.

I have found in Using Phar Archives: Introduction tutorial that it's possible to do next:

<?php
include 'composer.phar';
?>

But i get next error when trying to do same:

phar "/var/www/.../composer.phar" is API version 0.0.0, and cannot be processed

#0 /var/www/.../composer.phar(13): Phar::mapPhar('composer.phar') 
...

My phpinfo output shows next information:

Phar EXT version 2.0.1, Phar API version 1.1.1

0m3r
  • 33
  • 6

1 Answers1

0

You need to do:

require 'vendor/autoload.php';
use <NAMESPACE>\<LIBRARY>;

to load whatever your composer libraries are. composer.phar is the script that actually goes and retrieves libraries for you, based on the contents of your composer.json file.

If you want to actually run composer.phar from a PHP script, keep it simple and just use the shell (e.g. using backticks, shell_exec(), etc).

$output = `<path_to_composer>/composer.phar [options]`;

What you're trying to do is meant for libraries that have been packaged as a phar, not applications.

WWW
  • 9,734
  • 1
  • 29
  • 33
  • I think OP actually wants to execute composer-related actions. – Evert Feb 08 '13 at 15:56
  • @Evert I'll let him clarify - I'm not sure why you'd want to do that from a PHP script. Hmm, re-reading, I think you're right. – WWW Feb 08 '13 at 15:57
  • Thanks guys. 0.Yes, @Evert is right. 1.I can not use a shell and shell_exec. – 0m3r Feb 11 '13 at 08:40