4apps / api-stats-php
PHP library for Api stats portal
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Type:project
Requires
- php: >=8.1
- mongodb/mongodb: ^1.11
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-10-22 05:22:16 UTC
README
Installation / Usage
Installation via composer: composer require 4apps/api-stats-php
Usage example (for php 8.1+):
use 4Apps\ApiStats; $mongoDbConfig = [ 'string' => 'mongodb://mongodb:27017', 'dbname' => 'apiStatistics' ]; $apiStats = ApiStats($mongoDbConfig); // Create event $eventId = $apiStats->logApiStatistics($scope, $service, $contextName, $methodName, $endpointUrl); // Failed $apiStats->updateApiStatistics($eventId, failed: true); // Retry $seconds = 60; // Retry timeout $apiStats->updateApiStatistics($eventId, retry: true, retrySeconds: $seconds); // Success $apiStats->updateApiStatistics($eventId); // Custom timestamp $apiStats->updateApiStatistics($eventId, timestamp: time());
Development
To make changes to the library do this:
python3 -m pip install -r requirements.txt
fab docker.install
docker compose exec develop bash
- Repository contains configuration files for vscode container extension.
Testing
To run phpunit tests, bring up development docker machine and run phpunit: ./vendor/bin/phpunit