This time we will learn how to install and configure Windows. Actually the documentation is very clear, but here I write only to simply translate and give more understanding to the readers of this article.
Install Composer
In this tutorial, we use Composer to install Laravel.
1. You can download composer here or you can directly visit the site official composer choose composer for windows.
2. Run the downloaded file using run as administrator
3. Then a window will appear like below and select install for all users
4. Furthermore, when a window appears as below, please press next
5. After that, select the address where you installed PHP, if you use Xampp, it will be directed to the PHP path directly by the installer, and select next
6. Continue with the install process, and please open your command prompt and type composer -v. If installation successful it will appear like this.
Create Laravel Project Via Composer
1. We create a project called learn-laravel by typing the command as below in the command prompt you
composer create-project laravel/laravel learn-laravel
This command is a command for Composer to create a new Laravel project. You can put projects learn-laravel in any directory.
2. Move to learn-laravel folder, or type command as below
cd learn-laravel
3. After moving to the learn-laravel directory, you can run the project by writing
php artisan serve
then it will appear as below
[Fri Dec 3 12:33:07 2021] PHP 8.0.3 Development Server (http://127.0.0.1:8000) started
after that you can run the learn-laravel project by writing http://127.0.0.1:8000 in your browser.
Create a Laravel Project Via Laravel Installer
This feature makes it easier for us to create a new project. Why? because we don't need to re-download some source. This feature is a bit more step-by-step for initial use, however. Because we have to download installer and then have to change our path environment variables first. Here are the steps early so that we can use the laravel installer.
1. Download Laravel Installer
To install laravel installer we can use global function in composer. Type command below on your command prompt.
composer global require laravel/installer
the command above is used so that we can use the laravel installer without downloading repeat.
result
2. Edit Environment Variables
after the installer is successfully installed.
You can set environment variable on your system.
how to:
a. Type environment on the windows menuas shown below.
b. Then Edit the system environment variables.
c. Then select path and edit as shown below
d. Add 1 path for the environment variable by clicking new and writing path. You can see image below
or you can copy text below
%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
e. Next press ok then ok.
3. Create a New Project and Run it
After you have finished changing the environment variable, you can close the previous command prompt and open a new command promptand follow these steps.
a. navigate to the directory you want (not necessarily in xampp). Here I give an example on xampp.
cd /xampp/htdocs
b. Then create a new project with the command
laravel new learn-laravel-2
Wait for the process to finish.
c. then move to your project folder
cd learn-laravel-2
d. After moving to the learn-laravel-2 directory, you can run the project by writing
php artisan serve
then it will appear as below
[Fri Dec 3 12:33:07 2021] PHP 8.0.3 Development Server (http://127.0.0.1:8000) started
after that you can run the learn-laravel project by writing http://127.0.0.1:8000 in your browser.
Hopefully this is useful :)