Updating $PATH for Laravel in Ubuntu 20.04
In order to get #laravel
command to work make sure its included in the $PATH
$ composer global require laravel/installer
Changed current directory to /home/admin/.config/composer
Using version ^4.0 for laravel/installer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 12 installs, 0 updates, 0 removals
- Installing symfony/polyfill-php80 (v1.18.1): Downloading (100%)
- Installing symfony/process (v5.1.5): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.18.1): Downloading (100%)
- Installing symfony/polyfill-intl-normalizer (v1.18.1): Downloading (100%)
- Installing symfony/polyfill-intl-grapheme (v1.18.1): Downloading (100%)
- Installing symfony/polyfill-ctype (v1.18.1): Downloading (100%)
- Installing symfony/string (v5.1.5): Downloading (100%)
- Installing psr/container (1.0.0): Downloading (100%)
- Installing symfony/service-contracts (v2.2.0): Downloading (100%)
- Installing symfony/polyfill-php73 (v1.18.1): Downloading (100%)
- Installing symfony/console (v5.1.5): Downloading (100%)
- Installing laravel/installer (v4.0.4): Downloading (100%)
symfony/polyfill-intl-normalizer suggests installing ext-intl (For best performance)
symfony/polyfill-intl-grapheme suggests installing ext-intl (For best performance)
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
symfony/console suggests installing psr/log (For using the console logger)
Writing lock file
Generating autoload files
10 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Notice the command is still not available
$ laravel
laravel: command not found
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
That’s because you need to update the path in /etc/environment
, using vi or nano edit this file and append the path details
$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/admin/.config/composer/vendor/bin"
Final step is to source /etc/environment
so that it can be read into your current session
$ source /etc/environment
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/admin/.config/composer/vendor/bin
$ laravel
Laravel Installer 4.0.4