Skip to content

Official PHP client library to interact with residue logging server seamlessly.

License

Notifications You must be signed in to change notification settings

abumq/residue-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Residue PHP Client

A very simple, secure PHP library to interact with residue seamlessly.

This library provides interface for connecting and interacting with residue server seamlessly, means, once you are connected this module takes care of expired clients and keep itself updated with latest parameters and ping server when needed to stay alive.

Version GitHub license

Donate

Dependencies

This library currently depends on following binaries

  • ripe
  • nc (netcat)

Please check out sample configuration to find out more

Progress

This library does not currently support following features:

  • Unknown clients
  • Plain log request
  • Custom key size

Config

Config Type Description
url String Combination of URI and port of residue server
application_id String Application ID for %app format specifier
rsa_key_size Number RSA key size (generated randomly) for unknown clients
time_offset Number Log time offset (in seconds)
client_id String Client ID that server knows this client as
client_private_key String Full path of RSA private key
client_key_secret String Secret (passphrase) for encrypted private key (if any)
server_public_key String Full path to server public key (if any)
ripe_bin String Command to successfully run ripe binary using user that will run your PHP script

Problems occur if the user running the script cannot run ripe or nc binaries. You may also be interested in following issues on stackexchange network
* how to set crontab PATH variable
* How to get CRON to call in the correct PATHs
* How to set cron PATH globally (i.e. for all users) permanently?
nc_bin String Command to successfully run nc binary using user that will run your PHP script
session_dir String Full path to an empty directory for storing temporary objects by library (e.g, connection params etc). This directory must not contain anything and it may be cleared at times by this library.
reset_conn Number Forcefully resets the connection after this time (in seconds)
internal_log_file_limit Number Maximum limit (in KB) for internal logging file (stored in <session_dir>/internal.log). Defaults to 2048 KB

Sample Config

{
    "url": "localhost:8777",
    "application_id": "com.amrayn.residue.php.sampleapp",
    "rsa_key_size": 2048,
    "time_offset": 0,
    "client_id": "muflihun00102030",
    "client_private_key": "keys/muflihun00102030.pem",
    "client_key_secret": "",
    "server_public_key": "keys/server.pub.pem",
    "ripe_bin": "ripe",
    "nc_bin": "nc",
    "session_dir": "/tmp/resphp/",
    "reset_conn": 120,
    "internal_log_file_limit": 2048
}

Usage

// initialize only once in the beginning of the script
\residue\Residue::init("/path/to/client.conf.json");

$logger = new \residue\Logger("sample-app");

// we're all set! (if everything was good in client.conf.json file)

$logger->debug("another");

// array
$logger->info([1, 2]);

// object
$logger->info("blah %s this", $myCar);

// number
$logger->info(1234);
$logger->info(1234.233);

// formatted (see http://php.net/manual/en/function.sprintf.php)
$logger->info("test %s %s", 1, 2);


// verbose log
$logger->verbose(9, "this is msg %d ---", 123);

License

Copyright 2017-present Amrayn Web Services
Copyright 2017-present @abumusamq

https://github.com/amrayn/
https://muflihun.com
https://amrayn.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.