Learn About API Testing Tool in Laravel 9 Tutorial

Reading Time: 4 minutes
2,110 Views

For API testing, we generally use many tools or browser extensions, for example – postman. Inside this article we will discuss a API testing tool in laravel 9, which we can create by the help of a composer package.

This tutorial will be step by step guide to install, create & test api tool in laravel 9.

This composer package provides the API testing UI, request flow, parameters etc. Here you will get the complete guide to develop API testing tool in laravel 9.

We can test all restful web services by this tool as well.

Learn More –

Let’s get started.

Laravel Installation

Open terminal and run this command to create a laravel project.

composer create-project laravel/laravel myblog

It will create a project folder with name myblog inside your local system.

To start the development server of laravel –

php artisan serve

URL: http://127.0.0.1:8000

Assuming laravel already installed inside your system.

Create Database & Connect

To create a database, either we can create via Manual tool of PhpMyadmin or by means of a mysql command.

CREATE DATABASE laravel_app;

To connect database with application, Open .env file from application root. Search for DB_ and update your details.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_app
DB_USERNAME=root
DB_PASSWORD=root

Install laravel-api-tester Package

Open project into terminal and run this composer command.

$ composer require asvae/laravel-api-tester

RESTful APIs Development

To learn about the complete concept of developing restful apis in laravel 9 using passport, Click here.

We will test the above created apis into this api testing tool of laravel. This API tool is not only for APIs even we can test our application normal routes as well using GET & POST request type.

Add Example Route

Open api.php from /routes folder and add this.

//...

Route::get('sample-message', function () {

    return response()->json(array(
        "status" => 1,
        "message" => "API testing tool is working fine"
    ));
});

Application Testing

Run this command into project terminal to start development server,

php artisan serve

URL to open API Tester – http://127.0.0.1:8000/api-tester

This is similar to all API testing tools, but this time we have developed using a composer package of laravel.

Testing Example Route in Tool

If we scroll down the above screen, we should see the output.

We hope this article helped you to learn about Learn About API Testing Tool in Laravel 9 Tutorial in a very detailed way.

Online Web Tutor invites you to try Skillshike! Learn CakePHP, Laravel, CodeIgniter, Node Js, MySQL, Authentication, RESTful Web Services, etc into a depth level. Master the Coding Skills to Become an Expert in PHP Web Development. So, Search your favourite course and enroll now.

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.