Bash Script not executing git pull - laravel

I'm executing a bash script from laravel controller using symphony/process. The bash script is executing but only few of the lines only. Other lines are throwing no output at all.
This is what I'm using to execute bash script from laravel controller.
$process = new Process(['/home/ubuntu/deploy.sh']);
process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
This is triggering the deploy.sh file. and the code of deploy.sh is :
#!/bin/sh
cd /var/www/foodie #working
# activate maintenance mode
php artisan down #working
# update source code
git pull --progress #not working
# update PHP dependencies
composer install --no-interaction --no-dev --prefer-dist #not working
# --no-interaction Do not ask any interactive question
# --no-dev Disables installation of require-dev packages.
# --prefer-dist Forces installation from package dist even for dev versions.
# update database
php artisan migrate --force #working
# --force Required to run when in production.
# stop maintenance mode
php artisan up #working
In all the code php based commands and cd command only working. All other not getting exeuted.
When I execute same file like /home/ubuntu/deploy.sh all commands are working.
I have tried executing the same code manually with home/deploy/deploy.sh and all working fine.
I'm expecting the same should work when executed through symphony/process from laravel controller.

Related

laravel new sh: composer: command not found

The problem happens whenever I call the Laravel installer: laravel new app.
I get sh: composer: command not found
When I call composer create-project --prefer-dist laravel/laravel app everything works fine.
I'm using zsh and my export paths looks as follows:
export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH=/opt/homebrew/bin:$PATH
export ZSH="/Users/konstantinkrumov/.oh-my-zsh"
export PATH=~/.composer/vendor/bin:$PATH
I also have an alias for composer
alias composer="php /usr/local/bin/composer/composer.phar
When I run which composer I get: composer:
aliased to php /usr/local/bin/composer/composer.phar
So far I have tried to:
Move composer.phar into /usr/local/bin/
Reinstalled composer
Changed the alias path to php /usr/local/bin/composer/composer
Tried making a symlink as suggested in this stackoverflow question
non of the above seem to work
The best solution which I was able to find was to make a function in the ~/.zshrc file.
Function looks like this:
ln() {
composer create-project --prefer-dist laravel/laravel $1;
}
This way I can run ln app and generate a new laravel app with a shorter syntax.
I was unable to figure out why running laravel new app gave the following output: sh: composer: command not found and failed to generate a new app.
If you are on macOS, You can do:
cd /usr/local/bin
mv composer.phar composer
sudo chmod +x composer

Run demo locally fails: Service 'consumer' failed to build

When Tring to build the API-Platform demo has described on the GitHub repository the building appears to fail on PHP step:
Step 28/36 : RUN set -eux; mkdir -p var/cache var/log; composer dump-autoload --classmap-authoritative --no-dev; composer run-script --no-dev post-install-cmd; chmod +x bin/console; sync
---> Running in 7c9b0eb0fd97
+ mkdir -p var/cache var/log
+ composer dump-autoload --classmap-authoritative --no-dev
Generating optimized autoload files (authoritative)
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
Generated optimized autoload files (authoritative) containing 4776 classes
+ composer run-script --no-dev post-install-cmd
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [OK]
Executing script assets:install public [OK]
Executing script security-checker security:check [KO]
[KO]
Script security-checker security:check returned with error code 1
!!
!! The web service failed for an unknown reason (HTTP 403).
!!
!!
Script #auto-scripts was called via post-install-cmd
ERROR: Service 'consumer' failed to build: The command '/bin/sh -c set -eux; mkdir -p var/cache var/log; composer dump-autoload --classmap-authoritative --no-dev; composer run-script --no-dev post-install-cmd; chmod +x bin/console; sync' returned a non-zero code: 1
I try the following commands:
docker-compose build
I opened an issue too https://github.com/api-platform/demo/issues/192
i think the service stopped ..
https://packagist.org/packages/sensiolabs/security-checker
use this instead
https://github.com/fabpot/local-php-security-checker

Composer: Command Not Found on Mac

I have installed Composer as per the instructions command not found
After installing I get the prompt that Composer is successfully installed but when I go to check the version it gives me error "Composer: Command Not Found"
I have been looking how to fix this issue and I had to read and understand little bit and the environment variables on MAC.
I understand the issue looks simple but it will get over complicated if you didn't understand how to install composer probably.
Solution 1
I found this solution here: https://duvien.com/blog/installing-composer-mac-osx
Open a terminal and navigate to your user directory, ie cd /User//
Run this command shown below to download Composer. This will create a Phar (PHP Archive) file called composer.phar:
curl -sS https://getcomposer.org/installer | php
Now we move composer.phar file to a directory
sudo mv composer.phar /usr/local/bin/
We want to run Composer with having to be root al the time, so we need to change the permissions:
sudo chmod 755 /usr/local/bin/composer.phar
Next, we need to let Bash know where to execute Composer:
nano ~/.bash_profile
Add this line below to bash_profile and save
alias composer="php /usr/local/bin/composer.phar"
and then run this command:
source ~/.bash_profile
Finally, run:
composer --version
Solution 2:
I understand that the first command you will find online when you try to google this issue would be
curl -sS https://getcomposer.org/installer | php
But actually this is the main terminal installation but sometimes I wanted to manually install the composer, so this 2nd solution about manually installing the composer in specific directory
First of all you need to understand where are you now on the terminal
use
pwd
and then install composer manually using the following commands
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') ==='baf1608c33254d00611ac1705c1d9958c817a1a33bce370c0595974b342601bd80b92a3f46067da89e3b06bff421f182') { echo 'Installer verified'; } else { echo 'Installer corrupt';
unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
to use it on that case you will read on the terminal to use this composer installation use
Use it: php composer.phar
so just write
php composer.phar
and it should be working.... one more thing, during this installation you can install the composer to specific directory / project folder... in that case you can use a flag with command No.4 to tell the terminal to install the composer in specific directory...this flag is --install-dir=your-directory-path
and you will the terminal this time after installing composer asking you to use the following path to call the composer
Use it: php /Users/muatafa/composer.phar
if you want to read more about this issue, I think you must read the composer documentation how to install it>>> https://getcomposer.org/download/
that's how I solved my current issue... if you still have any issues comment on this replay & Hopefully we can figure it out!
I had the same problem. "composer require something" works if installed in global and not locally.
If you install composer locally you'll then install dependencies using "php composer.phar require nameofyoudependency"
To install globally open a terminal to install as mentionned on the composer website. Then run "sudo mv composer.phar /usr/local/bin/composer"
Now you can use "composer" directly to install dependencies like => "composer require something/sdk"
the composer you installed is still named /usr/local/bin/composer.phar - look in the second yellow/brownish line in your output. Just rename it to just composer
Your composer command is not set to path, use
export PATH=$PATH:/usr/local/bin/
I had the same issue, After installing composer using the command line on their website. I forgot to put composer.phar into a directory on my PATH, so it can simply be called from any directory (Global install). and then I ran this command "sudo mv composer.phar /usr/local/bin/composer" and it was resolved
I figured out. in place of "composer require twilio/sdk" I needed to use
"composer.phar require twilio/sdk" since I am on mac. It worked

command line composer command not defined

I am following the composer developer Tutorial: https://hyperledger.github.io/composer/tutorials/developer-guide.html
Everything worked till the point when I am running from the command line:
$ composer archive create -a dist/my-network.bna --sourceType dir --sourceName .
-bash: fds: command not found
The composer command was not found. When built by npm install the script can execute the composer command within the package.json
Next I installed php composer from: https://getcomposer.org - Which might be the wrong package?
$ composer network deploy
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "network" is not defined.
My 2 questions: is this the right package, if not how can I remove it safely?
Furthermore, how can I execute the composer command.
You need to npm install -g composer-cli -- please refer to the documentation.

Try running composer in git bash and composer not found

Most of the time I run composer using git bash and using laptop, now using desktop and I try to run composer using git bash again, it show
bash: composer: command not found
Does anyone has the same problem with me?

Resources