Slide 1
Most trusted JOB oriented professional program
DevOps Certified Professional (DCP)

Take your first step into the world of DevOps with this course, which will help you to learn about the methodologies and tools used to develop, deploy, and operate high-quality software.

Slide 2
DevOps to DevSecOps – Learn the evolution
DevSecOps Certified Professional (DSOCP)

Learn to automate security into a fast-paced DevOps environment using various open-source tools and scripts.

Slide 2
Get certified in the new tech skill to rule the industry
Site Reliability Engineering (SRE) Certified Professional

A method of measuring and achieving reliability through engineering and operations work – developed by Google to manage services.

Slide 2
Master the art of DevOps
Master in DevOps Engineering (MDE)

Get enrolled for the most advanced and only course in the WORLD which can make you an expert and proficient Architect in DevOps, DevSecOps and Site Reliability Engineering (SRE) principles together.

Slide 2
Gain expertise and certified yourself
Azure DevOps Solutions Expert

Learn about the DevOps services available on Azure and how you can use them to make your workflow more efficient.

Slide 3
Learn and get certified
AWS Certified DevOps Professional

Learn about the DevOps services offered by AWS and how you can use them to make your workflow more efficient.

previous arrow
next arrow

How to Create REST API in Laravel.

API is also known as Web services. Web services is very important when you are creating web and Mobile app. You require API in mobile application development. If you Don’t know how to create REST API in laravel then just follow the below Steps, i’m explaining everything step-by-step.  

Step 1: Install Laravel

In the first step, we require to get fresh Laravel application using below command, So open your terminal OR command prompt and run below command:

composer create-project --prefer-dist laravel/laravel laravel_api "5.4.*"

Step 2: Make Database Configuration

Step 3: Make Authentication scaffold

Make Laravel Authentication scaffold by below command and migrate

1. php artisan make:auth

2. php artisan make:auth

Step 4: Add Dummy Data in Table.

Add some dummy data in users table so that when we call our API then it return the dummy data.

Step 5: Create the Controller.

Now, lets make a Controller in which we call country table to call the data from table. first, create a directory named API and under api create a Controller and put the below code.

<?php

namespace App\Http\Controllers\api;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use App\User;

class apicontroller extends Controller
{
   
   public function index()
    {
        return User::all();
    }
}

See the below image of Controller.

Step 6: Create API Route.

Make api route to call our API. Go to routes/api.php and put the below code.

Route::get('countries', 'api\apicontroller@index');

See the below Image

Step 7: Call API Route.

Now we call the API route to access our Data. API URl is like

www.domainname.com/api/your_api_route.

I’m running my project in local so my url is http://localhost/laravel_api/public/api/countries

Open the API url to access the data. See the Below Image