
Step 1: Install laravel-api-tester Package
composer require asvae/laravel-api-tester
After successfully install package, you have to open config/app.php file and add service provider and alias.
config/app.php
'providers' => [
....
Asvae\ApiTester\ServiceProvider::class,
]
.....
You can publish the default configuration file by following command:
php artisan vendor:publish --provider="Asvae\ApiTester\ServiceProvider"
Step 2: Create API Route
Route::get('users',function(){ $users = \App\User::get(); return response()->json($users);});
Go This Link
http://localhost:8000/api-tester
Face Some Problem Work Some Step : Original link
here what i found after carefully reading core files of api-tester, and it works for me in laravel version > 5.8
you need to change some files in vendor\asvae\laravel-api-tester folder
Step 1:
first of all open vendor\asvae\laravel-api-tester\resources\views\api-tester.blade.php
and replace some code
From:
<link media="all" type="text/css" rel="stylesheet" href="{{ route('api-tester.file', ['file' => 'api-tester.css']) }}">
To:
<link media="all" type="text/css" rel="stylesheet" href="{{ route('api-tester.file', ['_file' => 'api-tester.css']) }}">
also need to do some more in same file:
From:
<script src="{{ route('api-tester.file', ['file' => 'api-tester.js']) }}"></script>
To:
<script src="{{ route('api-tester.file', ['_file' => 'api-tester.js']) }}"></script>
Step 2:
if you are not running your system on PHP v7.4 then skip the step 2
open vendor\asvae\laravel-api-tester\src\Storages folder and find JsonStorage.php
on line # 57 Replace the code
From:
$this->path = implode($path,'/');
To:
$this->path = implode('/',$path);
Step 3:
open vendor\asvae\laravel-api-tester\src\Entities folder and find RouteInfo.php
on line # 190 Replace the code
From:
if (is_string($uses) && str_contains($uses, '@')) {
To:
if (is_string($uses) && Str::contains($uses, '@')) {
also dont forget to add below line at top of the page
use Illuminate\Support\Str;
that's it Now enjoy with your output.
Great tutorial on testing Laravel REST APIs! For those looking to deepen their Laravel skills, I highly recommend checking out the Best Laravel Training Course in Surat. It’s a fantastic resource for both beginners and advanced developers.
LikeLike