Raviya Technical
Published in

Raviya Technical

Laravel with Packages | API Testing Tools in Laravel

In this post, I would like to create your laravel API testing tool in your laravel 5, laravel 6, laravel 7, laravel 8, and laravel 9 application. you can install the API tester tool in your laravel app. we will use the laravel-api-tester composer package for the laravel tool.

As we know laravel framework is the most popular farmworker in the world today. laravel is popular for front-end like vuejs, angularjs, react js, etc as well as most popular for back-end side. Laravel is popular for the back-end for API creation.

Today in the market laravel is famous for APIs building. almost code PHP project converting in Laravel framework because laravel provides better structure, follow MVC and main key security.

Laravel creates APIs using their MVC pattern. if you are new you don’t know how to create an API then you can follow the below link for API create, here I create RESTFul route API so you can create your own by the following tutorial:

How to create REST API in Laravel 5 ?.

For security, laravel provides passport and JWT security for API creation you can also follow the below tutorials for passport and JWT APIs.

  1. Laravel 5 — How to create API Authentication using Passport?

2. Laravel 5.2 API using JWT authentication tutorial from scratch example

As you know above both tutorials will help to understand how to create tutorials and tutorials with a perfect security protection guard. now we will proceed with how to check. now we will use the laravel-api-tester composer package that can help to easily test your all-created APIs and you can also save it.

So let’s install the laravel-api-tester composer package then we will create a simple one api for testing and you will get a layout like as below:

Preview:

Step 1: Install the laravel-api-tester Package

Here, we will add the laravel-api-tester package for api tester tools so open your terminal and run the below command:

composer require asvae/laravel-api-tester

After successfully installing the package, you have to open the config/app.php file and add the service provider and alias.

config/app.php

'providers' => [....Asvae\ApiTester\ServiceProvider::class,].....

You can publish the default configuration file by the following command:

php artisan vendor:publish --provider="Asvae\ApiTester\ServiceProvider"

Step 2: Create API Route

In this step, we need to create an API route for listing users' lists. so open your routes/api.php file and add the following route.

routes/api.php

Route::get('users',function(){$users = \App\User::get();return response()->json($users);});

Ok finally we got a full example, you have to make sure to add some dummy records on the users table, so run our example so run below command:

php artisan serve

Now you can open the below URL on your browser:

http://localhost:8000/api-tester

I hope it can help you...

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store