Install Laravel and Basic Setup Configuration for Beginners

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, avr: 5.00)

Laravel is a popular open-source PHP web framework based on the MVC (Model View Controller) architectural pattern, This is free and easy to install Laravel with composer, the purpose of Laravel to improve the quality of PHP code with standard design practices. Using Laravel, you can save hours of development time and reduce thousands of lines PHP code.

In this article, we will present you at a simple approach how to install Laravel and basic setup configuration for beginners guide.


Before starting with this tutorial, make sure you have installed XAMPP if you will run Larevel Project in localhost, we also recommended it’s better you have basic knowledge to use Command prompt or Terminal.

Step 1: Install Composer

The composer is an application-level package manager for the PHP programming. It allows to declare the libraries PHP project that will manage, install and update. Composer can include third party ready-to-use packages and libraries to PHP  Laravel project and manage them all in one place using a file composer.json

To install composer please download directly Composer on the official website and run the installer. Once the Composer is installed, open the Command prompt or Terminal then type composer. If it is running and working properly you will see the output like below

Install Composer
Install Composer

Step 2: Install Laravel

Now it’s time to install Laravel on our system using composer. Laravel utilizes Composer to manage its dependencies and Packagist.

The simple way to install Laravel by issuing the Composer create-project command in your terminal and followed by the directory name myblog for your Laravel project

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

Completed installation process you will see on the screen as the following

Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
> @php artisan key:generate --ansi
Application key set successfully.

Step 3: Create a Database

Laravel has a cutting-edge tool for interacting with databases. It’s easily designed and modify a database in a platform-independent. The database types that Laravel supports (MySQL, SQLite, PostgreSQL and MSSQL).

Active record on Laravel it is called Eloquent to interacting with a database, it can create, retrieve, update, and delete the database records without needing to write a single line of SQL.

Laravel need Database to store data structure and organized information. Most databases contain multiple tables, which may each include several. For this tutorial, we are using MySQL server and phpMyAdmin.

Create a Database in phpMyAdmin
Create a Database in phpMyAdmin
  1. If you can’t see a section “Create new database”, click New on the left-hand side of phpMyAdmin
  2. Type a name for your database on “Create database”
  3. Click Create button to create Database

The database now is ready to set up the fields. You can specify whether a field is for text, for numbers, and other values, etc. Let’s do the next step.

Step 4: Connect Laravel to Database

Once the database is created, you need to tell your Laravel project the details about the database. Laravel has a pretty simple way connecting with databases and running queries. The database configuration file is located in your Laravel Project directory .env. In this file you may define all of your database connections. Modify the following property on the red line according to your database settings.


Step 5: Run Migration (Optional)

Laravel migrations are version control for database, allowing to share and modify easily the application’s database schema, to test Laravel success connecting to the database you should run the migration command. Laravel project by default comes with some default table for storing users and their password request. once you run migrate command you will see on screen command prompt or Terminal as the following.

λ php artisan migrate
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table

Step 6: Test Laravel Project on the Browser

You can now view this page in your web browser by visiting your server’s domain name or public IP address if you are working on localhost you may go with URL  http://localhost:8000/

install laravel
Test Laravel on Browser

Note: If you want to change default port 8000, you can also run php artisan with another port php artisan serv --port=1010

If this article Install Laravel and Basic Setup Configuration for Beginners could help you, please rate above Star button rating and share to help others find it! Feel free to leave a comment below


About the Author: Adzan

A writer and blogger for Internet Technology. Loves to explore features update about the Programming language, Software developer and etc..