In this post, I'll show you how to make your own laravel API testing tool for Laravel 5, Laravel 6, Laravel 7, Laravel 8, and Laravel 9. In your Laravel app, you can install the API tester tool. For the laravel tool, we'll utilise the composer package laravel-api-tester.
As we all know, the Laravel framework is the most widely used farmworker nowadays. Laravel is popular for front-end frameworks like as vuejs, angularjs, and react js, as well as for back-end development. Laravel is a popular back-end framework for creating APIs.
Laravel is well-known in the market for creating APIs. Almost all PHP projects are being converted to the Laravel framework since it has a superior structure, follows MVC, and has main key security.
We'll utilize the laravel-api-tester composer package, which allows you to quickly test and save all of your APIs.
So, first, let's install the laravel-api-tester composer package. Next, we'll create a simple one-api for testing.
Step 1: Install laravel-api-tester Package
Open your terminal and type the following command to install the laravel-api-tester package for api tester tools:
composer require asvae/laravel-api-tester
After the package has been properly installed, edit the config/app.php
file and add the service provider and alias.
config/app.php
'providers' => [
....
Asvae\ApiTester\ServiceProvider::class,
]
The default configuration file can be published using the command:
php artisan vendor:publish --provider="Asvae\ApiTester\ServiceProvider"
Step 2: Create API Route
This phase requires the creation of an API route for listing user lists. So go to routes/api.php
and add the following route.
routes/api.php
Route::get('users',function(){
$users = \App\User::get();
return response()->json($users);
});
Finally, we have a complete example. Make sure to add some dummy records to the users table before running our example.
php artisan serve
You can now open the following URL in your browser:
http://localhost:8000/api-tester
I hope you will like the content and it will help you to learn Learn About API Testing Tool in Laravel 8 Tutorial
If you like this content, do share.