composer laravel code example

Example 1: create laravel 6 project using composer

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

Example 2: install laravel

composer create-project --prefer-dist laravel/laravel blog

Example 3: insall laravel

composer global require laravel/installer 
laravel new blog

Example 4: install composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '795f976fe0ebd8b75f26a6dd68f78fd3453ce79f32ecb33e7fd087d39bfeb978342fb73ac986cd4f54edd0dc902601dc') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Example 5: create project command in laravel

Before starting this hope you installed composer dependancy manager for PHP.
----------------------------------------------------------------------------- 
So if you want to create a project by name of 'first_laravel_app' in directory C:/xampp/htdocs/ then what you need to do is

Locate your project parent directory using cmd
>cd c:/xampp/htdocs

and fire this command 
>composer create-project laravel/laravel first_laravel_app --prefer-dist

And its done, this is really easy and it also creates Application Key automatically for you.
  
# I hope it will help you.
# Namaste

Example 6: installing laravel 8

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

Tags:

Misc Example