質問

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

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top