A step by step guide to setup Laravel environment 2019

At first, Laravel became the most starred PHP framework on GitHub and rose to the go-to framework for people all over the world. Laravel focuses on the end-user first, which means its focus is on simplicity, clarity, and getting work done.

My goal with this Laravel tutorial to create a guide for those just learning Laravel.

Step 1: Install Xampp

XAMPP is the most popular PHP development environment. XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to use.

XAMPP can be easily installed using the link below.

https://www.apachefriends.org/download.html

Laravel 5.7 requires PHP >= 7.1.3. Download the latest version (7.3.3/PHP 7.3.3).

After installing click to start Apache and MySQL. If the actions fail it means that the ports, we are trying to use are being used.

If the Apache Fails, click on the Config ->Apache (httpd.conf). Scroll down and find the listen port and then change it to 8081. Save and close.

If MySQL fails, go to start->services->MySql80 and stop this service. In most cases, this happens when MySQL Workbench is installed.

Step 2. Install Composer

The composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries. Hence we need to install composer before installing Laravel. Just follow the below URL and download the Composer-Setup.exe file.

https://getcomposer.org/download/

Step 3: Install Laravel

Now it’s time to install Laravel on our system using composer. This can be done by running the below command in the Command prompt.

composer global require "laravel/installer"


Step 4. Creating a New Application

After successful installation of Laravel, we can create a new app with the below command. MyFirstProject is the name of the project I want to create.

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

Step 5. Choosing the code Editor (OPTIONAL)

We can choose our favorite code editor for working with the project. However, I personally recommend Visual Studio Code (VS code). You can download it in the link below.

https://code.visualstudio.com

Step 6: Create the Database

Now we need to create a database for our project in our MySQL server. This can be easily done using phpMyAdmin.Open the link below.

http://localhost/phpmyadmin

Or go and click Admin button in XamppControl Panel. (Note: If you have changed the Apache port to 8081 use this: http://localhost:8081/phpmyadmin)

Now Enter username and password (As a default, the username will be root password will be empty).

  • Click on the New
  • Enter a database name
  • Press Create

Step 7: Modify Env File

Open the project folder in the code editor. My project is located at c:\user\user. Look for the .env file inside the root directory of our project. Add the database details in this file as below.

Then go to Config/Database also and add the database details.

Step 8: Migrate Database

To migrate the database we will use the below command:

php artisan migrate

If you are using visual studio code, click ctrl+`. This will open the terminal for you where you can write the above code. In case you are not using visual studio code, run the cmd, go to your project directory and write the above command.

Step 9: Add Authentication

Laravel provides a quick way to scaffold all of the routes and views you need for authentication using one simple command:

php artisan make:auth

You should use this command on fresh applications. As a result, this will install a layout view, registration and login views. As well as routes for all authentication end-points. Also, a HomeController will be generated to handle post-login requests to your application’s dashboard.

Step 10: Running the Application

You can run the application using the below command:

php artisan serv

This will open up a new tab on our browser with the URL below. This is the home page of our Laravel application.

http://localhost:8000


Also, the app can be run on another port using the command below.

php artisan serv --port=9000

This will open up our application in the port 9000

http://localhost:9000

Leave a reply


0 comments

SUBSCRIBE TO OUR NEWSLETTER