1. Go to this page and download the library: Download tp5er/think-http-logger 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/ */
tp5er / think-http-logger example snippets
return [
/*
* The log profile which determines whether a request should be logged.
* It should implement `LogProfile`.
*/
'log_profile' => \tp5er\think\HttpLogger\LogProfile\LogNonGetRequests::class,
/*
* The log writer used to write the request to a log.
* It should implement `LogWriter`.
*/
'log_writer' => \tp5er\think\HttpLogger\LogWriter\DefaultLogWriter::class,
/*
* The log channel used to write the request.
*/
'log_channel' => env('LOG_CHANNEL', 'file')
];
~~~
## 控制器中使用
~~~
use tp5er\think\HttpLogger\Middlewares\HttpLogger;
class Index extends BaseController
{
protected $middleware =[
HttpLogger::class
];
public function index()
{
return 'test HttpLogger';
}