Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

salkfdhjkh's avatar

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.

0 likes
5 replies
meeshka's avatar

@coldpizza

  1. Is composer installed and available globally on this new server?
  2. Is it the same user that you use for ssh and this automated process?
salkfdhjkh's avatar

@meeska Yes, composer is installed and I seem to be able to run it manually from any directory.

If I add;

whoami

to the post-receive hook, it returns the same user name as the ssh.

This is the error returned in the terminal;

remote: hooks/post-receive: line 16: composer: command not found
meeshka's avatar
meeshka
Best Answer
Level 5

@coldpizza Do you see any differences between $PATH on post-receive and ssh?

salkfdhjkh's avatar

@meeska Thanks, that seems to be it. I added the missing composer path into the post-receive script and it now runs properly. Cheers.

One more quick question. Is it advisable to run a test on whether the composer.json has changed before running composer install?

1 like
meeshka's avatar

@coldpizza There will be composer.lock that'll tell composer about it. So, no need to check if I understand your question correctly.

Please or to participate in this conversation.