P
P
Pianist2016-09-27 17:11:25
linux
Pianist, 2016-09-27 17:11:25

How to run composer install c bash script?

It is necessary to automatically deploy sites, i.e. merge with git
and install dependencies, import the base, etc.
The problem is when I try to install composer dependencies, as a result, nothing is displayed on the screen.
If you do any of the options manually, everything works, even when I specify incorrectly -d, it swears

<?php
exec("sh create_site.sh $sitename", $output);

echo '<pre>';
print_r($output);
echo '</pre>';


?>

#!/usr/bin/env bash

#Вариант 1 - не работает
cd /var/www/demo-sites/site1
/usr/local/bin/composer install 
#Вариант 2 - не работает
/usr/local/bin/composer install -d=/var/www/demo-sites/site1

#Вариант 3 - не работает
# скачал composer.phar и положил в папку
php composer.phar install -d=/var/www/demo-sites/site1

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pianist, 2016-09-28
@kzakhariy

The problem was solved like this:
with the help of 2> & 1 I caught the error:

The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly

it turned out that it was necessary to register COMPOSER_HOME and also specify --working-dir
# Composer install
COMPOSER_HOME="/usr/local/bin/composer"  php /usr/local/bin/composer  install  --working-dir=/var/www/sites/$SITE_NAME 2>&1  || true

R
romy4, 2016-09-27
@romy4

1. wrong path
2. in console and php under different users

O
Oleg Maksimenko, 2016-09-27
@olegprof

Should work with a global composer installation (it works for me):
cd /path/to/site
composer update
Correctly said above about the rights and paths.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question