How to install Laravel globally in Ubuntu

Sospeter Mong'are - Apr 28 '23 - - Dev Community

=============================================================

Open your terminal using Ctrl+Alt+T and type the following commands

Step 1: Install Laravel

composer global require "laravel/installer"
Enter fullscreen mode Exit fullscreen mode

Step 2: Add composer to path .bashrc file to access laravel globally

cd
sudo nano .bashrc
Enter fullscreen mode Exit fullscreen mode

Edit environment config file and add this line

export PATH="$PATH:$HOME/.config/composer/vendor/bin"
Enter fullscreen mode Exit fullscreen mode

Reload config path

source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Step 3: Create a new Laravel application

laravel new blog
Enter fullscreen mode Exit fullscreen mode

Step 4: Install missing packages and their dependencies

cd blog
composer install
Enter fullscreen mode Exit fullscreen mode

Step 5: Test the application

php artisan serve
Enter fullscreen mode Exit fullscreen mode

Open a web browser and visit localhost:8000 to see the laravel welcome page

Step 6: Stop server

Terminate php server in terminal by pressing Ctrl+C

Thus you have successfully installed laravel globally.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .