PHP code example of jorisvanw / apilogger

1. Go to this page and download the library: Download jorisvanw/apilogger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jorisvanw / apilogger example snippets


//in route.php or web.php
Route::middleware('apilogger')->post('/test',function(){
    return response()->json("test");
});

/**
 * View API logs
 *
 * @param \JorisvanW\Contracts\ApiLoggerInterface $logger
 *
 * @return \Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application|\Illuminate\View\View
 */
public function getApiLogger(ApiLoggerInterface $logger)
{
    $apilogs = $logger->getLogsPaginated();

    return view('apilog::index', compact('apilogs'));
}

/**
 * Delete API logs.
 *
 * @param \JorisvanW\Contracts\ApiLoggerInterface $logger
 *
 * @return \Illuminate\Http\RedirectResponse
 */
public function deleteApiLogs(ApiLoggerInterface $logger): \Illuminate\Http\RedirectResponse
{
    $logger->deleteLogs();

    return redirect()->back();

}
bash
php artisan vendor:publish --tag=config --provider="JorisvanW\Providers\ApiLogServiceProvider"
bash
php artisan migrate
bash
php artisan apilog:clear