PHP code example of sarahman / laravel-http-request-api-log
1. Go to this page and download the library: Download sarahman/laravel-http-request-api-log 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/ */
sarahman / laravel-http-request-api-log example snippets
ApiLog::all();
...
use GuzzleHttp\Psr7\Response;
use Illuminate\Database\Eloquent\Model;
use Sarahman\HttpRequestApiLog\Traits\WritesHttpLogs;
class ApiClient
{
use WritesHttpLogs;
...
...
public function __construct()
{
...
...
$this->enableLogging = false; // Overwrite the logging functionality being enabled or not.
}
...
...
public function sampleMethod()
{
...
...
$this->log('POST', $url, $options, new Response(200));
}
}
return [
/*
* If set to false, no api log will be saved to the database.
*/
'enabled' => true,
/*
* This model will be used to log activity.
* It should extend Illuminate\Database\Eloquent\Model.
*/
'api_log_model' => \Sarahman\HttpRequestApiLog\Models\ApiLog::class,
/*
* This is the database connection that will be used by the migration and
* the ApiLog model shipped with this package. In case it's not set
* Laravel's database.default will be used instead.
*/
'database_connection' => 'mysql',
/*
* This is the name of the table that will be created by the migration and
* used by the ApiLog model shipped with this package.
*/
'table_name' => '_api_calls',
];
bash
php artisan migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.