Logo
Findpro - Web App Development & Design Company is 2 Seconds Away. Have Patience

Building Your First Laravel Application (Blog Application)

Laravel is a free and open-source PHP Framework for Web Artisans based on Symfony that helps craft Web Applications following the MVC (Model View Controller) design pattern.

There are two ways to create a Laravel application, one is to use the Laravel installer. The other requires the Laravel package and for us to use a composer and a create-project command.

In this tutorial, we will use the latter.

Step by step guide on how to build your first Laravel (blog) application

Below is some information on the Laravel framework:

  • Framework: Laravel
  • Author: Taylor Otwell
  • Initial Release Date: June 2011
  • Current Version: 8 (September 8th, 2020)
  • Stable Release: 8.11.2 (October 28th, 2020)

What is Laravel ?

The short version, is that Laravel is a PHP MVC Framework. The long version would be, Laravel is a free and open-source PHP Framework for Web Artisans based on Symfony.

It helps craft Web Applications following the MVC (Model View Controller) design pattern. In order for us to better understand Laravel, we will build a simple blog application with Laravel from scratch.

Requirements: To create a Laravel application you will need a few tools installed in your computer.

These tools include:

  • PHP >= 7.3.
  • Database (MySql).
  • A localhost Web Server – In our case we’ll use WAMP (for Windows), LAMP (for Linux), or MAMP (for MacOs). This localhost webserver comes installed with latest PHP and MySQL database so you will not need to install them manually. To install either MAMP, LAMP, or WAMP go to http://ampps.com/downloads and choose the software your platform.
  • Composer – This is a dependency management software for PHP. To install the composer visit https://getcomposer.org/ and download it there for your platform.
  • Node.js – This is a free and open source JavaScript runtime environment that executes JavaScript outside of the browser. We will not write any Node.js code but it will be used in the background by Laravel to streamline our development.
  • Code editor – A code editor will be required. We recommend to use Visual Studio Code: It is free.
  • A browser – Google Chrome, Edge, Safari, or Mozilla Firefox will do just fine.
  • Background knowledge of the PHP Programming Language.

With our machine setup complete, it’s time to start developing.

Crafting a new Laravel application

As we mentioned before, there are two ways to create a Laravel application; one is using the Laravel installer and the other is through installing the Laravel package; and using a composer and a create-project command.

In this tutorial we will use the latter:

  • Open your console and cd to www directory in your MAMP, LAMP, or WAMP installation directory.
  • Type the following command:
composer create-project --prefer-dist laravel/laravel my-blog

It will create a directory called my-blog and load all the primary Laravel files there.

Configuring our Laravel application

After installing our Laravel application we will need to configure our database for it to work.

  • Go to http://localhost/phpmyadmin/
  • Create a new Database by clicking on new (shown below in red)

  • Name it my_blog and click Create

Now that we have a database we can proceed to set up the application to work with the database.

  • Open your file explorer and navigate to my-blog folder
  • Open the .env file in your code editor
  • Change the following in the file:-

APP_NAME key to name of your blog i.e. “My Blog”

DB_DATABASE key to database name i.e. my_blog

The final file should look like this:

Share:
Prev Post

Next Post

Comments:

Leave a Reply

Your email address will not be published.