- Is composer installed and available globally on this new server?
- Is it the same user that you use for ssh and this automated process?
Composer command not found
I have some Laravel sites with one particular host whereby Git deployment is pre-configured to work with Rsync and works without any problems.
I am now attempting to set up a similar Laravel/Git combination on a different host where I already have a number of sites under a reseller plan with WHM/Cpanel etc.
I have set up a Git repo and a post-recieve hook with the following code;
#!/bin/sh
# Set up PATH variable and export it
PATH="/home/username/bin":$PATH
export PATH
# App directories
APP_WEB_DIR="/home/username/laravelproject"
APP_GIT_DIR="/home/username/git/laravelproject.git"
# Checkout the last commit inside the web app directory
git --work-tree=${APP_WEB_DIR} --git-dir=${APP_GIT_DIR} checkout -f
# Run composer
cd ${APP_WEB_DIR}
composer install
# Ensure that storage's folder have write permission for the group
chmod -R g+w storage
# Optimizations
echo "Running optimizations"
php artisan config:cache
php artisan route:cache
The problem is that when I push, I get a Composer error of 'command not found' and while my push file appear on the server, Composer install does not run.
When I ssh onto the server, I can check composer runs from either the Git repo or the project directory so I am not sure why it reports this error.
While I can deploy the site by removing the Laravel vendor folder from the .gitignore file, I would prefer to be able to get it working with automated Composer install commands working.
Any tips appreciated.
Please or to participate in this conversation.