This post is in relation with this : Run composer with a PHP script in browser
My problem is to solve how to install a library without terminal and take in consideration some hosting do not accept the exec
command.
In summary the user can just click on the button to install apps with the library
Thank you.
I tried 2 solutions :
use Composer\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\StreamOutput;
putenv('COMPOSER_HOME=' . self::$root); // /www/mywebsite/shop/
putenv('COMPOSER_CACHE_DIR=' . CORE::BASE_DIRECTORY . '/Work/Cache/Composer/');
putenv('COMPOSER_HTACCESS_PROTECT=0');
first with this code
$stream = fopen('php://temp', 'w+');
$output = new StreamOutput($stream);
$application = new Application();
$application->setAutoExit(false);
$code = $application->run(new ArrayInput(array('command' => 'install tinify/tinify')), $output);
$result = stream_get_contents($stream);
var_dump($code);
var_dump($result);
The result is : (not work and nothing is installed)
int(1) string(0) ""
The second approach :
$input = new ArrayInput(array('command' => 'install tinify/tinify'));
$application = new Application();
$application->setAutoExit(false); // prevent `$application->run` method from exitting the script
$result = $application->run($input);
var_dump($result);
The result is : (not work and nothing is installed)
int(1)