spaf/count-y

简单的网站访问计数器库

2.0.2 2022-06-17 11:23 UTC

This package is auto-updated.

Last update: 2024-09-17 16:40:04 UTC


README

简单的PHP计数器

版本: 2.0.2

安装方法

  1. 进入项目文件夹(git/code仓库)/home/user/my-code
  2. 在代码文件夹的终端中运行命令
    composer require spaf/count-y;

基本用法(基于文件)

require __DIR__.'/vendor/autoload.php';

use spaf\county\Counter;
use spaf\county\storage\StorageFile;
use spaf\simputils\PHP;

PHP::init();

$c = new Counter(new StorageFile());
//  In case if the StorageFile is not specified, the value will be stored in memory (StorageMemory
//  class). So it will exist until end of the runtime/execution.
//$c = new Counter();

//  If you need events, first delegate/closure is an event function, the second - event condition. The first will work,
//  only if the second will return TRUE, or if condition delegate/closure is not specified.

//$c->add_event('My first test event', function ($value, $name) {
//	echo "EVENT of {$name} for value of {$value}\n";
//}, fn($v) => $v % 10 == 0 );

for ($i = 0; $i <= 105; $i++) {
	$c->visit();
	$c->visit();
	$c->visit();
}

echo "Test: {$c}";

就这么多。目前库只支持非常基础的功能。