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 8, 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 8.
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 8.
We can test all restful web services by this tool as well.
Learn How to create Admin panel in Laravel 8 using Voyager there, Click here.
Let’s get started.
Laravel Installation
We will create laravel project using composer. So, please make sure your system should have composer installed. If not, may be this article will help you to Install composer in system.
Here is the command to create a laravel project-
composer create-project --prefer-dist laravel/laravel blog
To start the development server of Laravel –
php artisan serve
URL: http://127.0.0.1:8000
Assuming laravel already installed inside your system.
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 8 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.
Create 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 8 Tutorial in a very detailed way.
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.