install laravel global code example

Example 1: install laravel globally

composer global require laravel/installer

Example 2: install laravel 5.8

composer create-project --prefer-dist laravel/laravel blog "5.8.*"

Example 3: how to install new project in laravel

You can create project by 2 ways:

First is installing it without defining version:
composer create-project laravel/laravel yourProjectName

Secondly you can install by defining version:
composer create-project laravel/laravel="VersionOfYourChoice" yourProjectName

Example 4: installing laravel 8

composer create-project --prefer-dist laravel/laravel ProjectName dev-develop