Installing and Setting up Laravel

Laravel is a modern PHP framework following the MVC design pattern. Today Laravel is almost everywhere in web application industry. Even for complicated systems like online banking systems, Laravel is used because of its beauty and simplicity. We have posted lots of Laravel tutorials but, I almost forgot to write down how to do Installing and Setting up Laravel in a proper way.

There are number of ways for installing Laravel. According to Laravel  documentation you can install Laravel using the following ways.

  • Via Laravel Installer
  • Via Composer Create-Project

In this tutorial we’re focusing on installing Laravel via Composer.

Prerequisites

Requirments for Laravel

To install and run laravel, you’re required to have following prerequisites installed on your machine.

So, before going any further make sure the above two requirements are done!

Installing via PHP Composer

Open up the Terminal and CD into a directory you want to install Laravel (mostly www folder in Wamp or htdocs in Xamp) and run the following command.

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

This will install Laravel. It will take few minutes to complete because this installation download and install all the dependencies as well. PHP composer does a great job for you.

Laravel is being installed

Now the installation is complete.

installation complete

Setting up Laravel

Next thing is setting up this fresh Laravel installation. To do that, open up .env.example  file in the root folder and update with your own configuration. For now, let’s update the following values.

DB_DATABASE=YOUR_DB_NAME
DB_USERNAME=MYSQL_USERNAME
DB_PASSWORD=MYSQL_PASSWORD

Now hit Save As and remove the .example part of the file name and save it as .env.

Great! Now we’ve done the basic installation and setting up your Laravel project.

Now it’s time to run the newly installed project. Make sure your Wamp or Xamp is running. Navigate to the directory you just installed Laravel from the browser. And click the public folder. Your fresh Laravel project will open up!

open laravel in browser

That’s it!

Follow the video tutorial for the simplified guide.

Leave a Reply

Your email address will not be published. Required fields are marked *