2

I am trying to migrate a ZF3 app to laminas. I have installed composer via apt, and added its vendor/bin to the PATH environment variable, for global usage:

$ composer -V
Composer version 2.2.4 2022-01-08 12:30:42

$ composer global config home
Changed current directory to /home/me/.config/composer
/home/me/.config/composer

$ export PATH={/home/me/.config/composer}:$PATH

Then globally installed laminas/laminas-migrate. Running it gets a "command not found" error:

$ composer global require laminas/laminas-migration
(output snip)
$ cd /var/www/my-project
/var/www/my-project $ laminas-migration migrate
laminas-migration: command not found

Output of PATH section from printenv:

PATH=/home/me/.yarn/bin:/home/me/.config/yarn/global/node_modules/.bin:/home/me/.yarn/bin:/home/me/.config/yarn/global/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

John Crest
  • 201
  • 1
  • 4
  • 24

2 Answers2

2

Bob Allen did a great job describing once how to install composer libraries globally. I don't know if this still applies after all these years, but worth a try. For what I have seen in your description, I think you migh have lost the very important bit of extending your PATH with folder, that contains executables:

export PATH=~/.composer/vendor/bin:$PATH

This line added to yours user account .bash_profile file will add ~/.composer/vendor/bin/ to the binarries collection that is scanned in case of executing a command.

yergo
  • 4,761
  • 2
  • 19
  • 41
  • Thanks for the reply. I do not have a .bash_profile, but at the bottom of my .bashrc i have the following line : export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" ...doesn't seem to be adding it? my .profile doesn't have anything either. – John Crest May 13 '22 at 20:37
  • And as with the previous answer, adding the /vendor/bin part on the end via the terminal still resulted in a "command not found" message. Adding export PATH="$HOME/.composer/vendor/bin:$PATH" to both .bashrc and .profile hasn't made any difference either. – John Crest May 13 '22 at 21:35
  • Try change this to `export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$HOME/.composer/vendor/bin:$PATH"` and relog to system. You need to make it through to see `.composer/vendor/bin` in your path from printenv – yergo May 14 '22 at 23:13
  • 1
    Finally! Yes this is now working, thank you very much. Not sure why the terminal wasn't adding it to my environment variables, but now i've added it to .bashrc it's working fine. Unfortunately the bounty expired, so i've just reinstated one and will award in 24 hrs. Thanks for the help. – John Crest May 15 '22 at 15:54
0

Do this instead.

export PATH=/home/me/.config/composer/vendor/bin:$PATH

Then close and reopen your terminal

  • Thanks for the reply, but after doing this i am still getting the "command not found" message. – John Crest May 13 '22 at 20:37
  • @JohnCrest Do these steps: 1. cd /home/me/.config/composer 2. run composer global require laminas/laminas-migration 3. put "export PATH=~/.composer/vendor/bin:$PATH" in the last line of your .bashrc 4. reopen your terminal – ramonthegreat May 14 '22 at 12:46