Composer libraries as global Linux commands


Composer global commands

There is a neat feature in Composer that allows to run libraries as Linux commands, which can speed up your development and maintenance of your projects. It also gives you more flexibility and can automate development process.

Example usage

For example you could create new projects in Laravel by running: laravel new project-name in your command line interface.

How to do it on Linux

You can navigate to /home/{user}/.composer/vendor/bin and see folders such as /laravel or /spark. After running bellow command in the terminal you will be able to run those commands.

export PATH="$PATH:$HOME/.composer/vendor/bin

Command may differ between Linux distributions but the idea is to add this bin folder path to global This way you can run installed libraries as usual commands:

admin@machine:/# spark
Laravel Spark Installer version 1.1.1

  command [options] [arguments]

  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages

Available commands:
  help      Displays help for a command
  list      Lists commands
  new       Create a new Spark application
  register  Register an API token with the installer
  token     Display the currently registered Spark API token