定制 travy/cake-tracking 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

travy/cake-tracking

Composer 安装命令:

composer require travy/cake-tracking

包简介

Request tracking middleware used for CakePHP 3 applications

README 文档

README

Build Status

Description

The Cake Tracking Plugin provides Middleware which will record all Request made to a web application. All logging can be customized per application but there is also a default logger which will write to the file system.

In addition, external IP addresses can be blacklisted from the site by adding the address to a blacklist file.

Installation

Add the package to your CakePHP projects composer.json

composer require travy/cake-tracking:1.0

Next, be sure to add the plugin to the config/bootstrap.php file by executing the following command in the command prompt

bin/cake plugin load cake-tracking

Now the Middleware can be loaded into the application pipeline by appending it to the MiddlewareQueue found in `src/Application.php'

class Application extends BaseApplication
{
    public function middleware($middlewareQueue)
    {
        $middlewareQueue
            ->add(ErrorHandlerMiddleware::class)
            ->add(AssetMiddleware::class)
            ->add(new RoutingMiddleware($this))
                
            //  add the TrackingMiddleware to the queue
            ->add(new \CakeTracking\Middleware\TrackingMiddleware());

        return $middlewareQueue;
    }
}

Finally, you should be able to add any custom configuration necessary to complete the environment.

If you want to use a custom Logger or blacklisting solution (perhaps to store data in a database) then you just need to create a class which implements either TrackingLoggerInterface or BlacklistRepositoryInterface. Then before adding the Middleware to the MiddlewareQueue, you can specify your custom classes using the built in setter calls.

class Application extends BaseApplication
{
    public function middleware($middlewareQueue)
    {
        //  supply the custom classes to the TrackingMiddleware object
        $trackingMiddleware = new \CakeTracking\Middleware\TrackingMiddleware();
        $trackingMiddleware->setBlacklistRepository(new BlacklistDatabaseRepository($configs));
        $trackingMiddleware->setLoggingOperation(new TrackingDatabaseLoggin($configs));
    
        $middlewareQueue
            ->add(ErrorHandlerMiddleware::class)
            ->add(AssetMiddleware::class)
            ->add(new RoutingMiddleware($this))
                
            //  supply the instantiated tracker to the queue
            ->add($trackingMiddleware);

        return $middlewareQueue;
    }
}

Configurations

The following configurations are optional but will be useful for system setup.

In config/app.php add the following:

'CakeTracking' => [
    'LogFile' => LOGS . 'bamboo.txt',
    'Blacklist' => LOGS . 'blacklist.txt',
],

The LogFile configuration will specify where all Requests should be logged.

Blacklist specifies the location of the blacklist on the system.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固