{"id":42218557,"url":"https://github.com/t3ran13/golos-php-event-listener","last_synced_at":"2026-01-27T01:35:29.862Z","repository":{"id":57064328,"uuid":"132273568","full_name":"t3ran13/golos-php-event-listener","owner":"t3ran13","description":"PHP event listener for STEEM/GOLOS blockchain","archived":false,"fork":false,"pushed_at":"2018-12-22T18:03:08.000Z","size":79,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-20T23:42:15.587Z","etag":null,"topics":["event-listener","golos","php","steemit","viz","whaleshares"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t3ran13.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-05T18:19:57.000Z","updated_at":"2018-12-22T18:03:10.000Z","dependencies_parsed_at":"2022-08-24T14:01:34.059Z","dependency_job_id":null,"html_url":"https://github.com/t3ran13/golos-php-event-listener","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/t3ran13/golos-php-event-listener","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t3ran13%2Fgolos-php-event-listener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t3ran13%2Fgolos-php-event-listener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t3ran13%2Fgolos-php-event-listener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t3ran13%2Fgolos-php-event-listener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t3ran13","download_url":"https://codeload.github.com/t3ran13/golos-php-event-listener/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t3ran13%2Fgolos-php-event-listener/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28795469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T01:07:07.743Z","status":"ssl_error","status_checked_at":"2026-01-27T01:07:06.974Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-listener","golos","php","steemit","viz","whaleshares"],"created_at":"2026-01-27T01:35:29.130Z","updated_at":"2026-01-27T01:35:29.832Z","avatar_url":"https://github.com/t3ran13.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# golos-php-event-listener\nPHP event listener for STEEM/GOLOS blockchains\n\n## Install Via Composer\n```\ncomposer require t3ran13/golos-php-event-listener\n```\n\n## Basic Usage\n\nFor working you app you need\n- database manager\n- events handlers\n- start script for cron\n\nExample below\n\n```php\n\u003c?php\nnamespace MyApp;\n\nuse GolosPhpEventListener\\app\\process\\BlockchainExplorerProcess;\nuse GolosPhpEventListener\\app\\process\\EventsHandlersProcess;\nuse GrapheneNodeClient\\Connectors\\ConnectorInterface;\nuse ProcessManager\\db\\RedisManager;\nuse ProcessManager\\ProcessManager;\n\nini_set('display_errors', 1);\nini_set('display_startup_errors', 1);\nerror_reporting(E_ALL);\ndefine('PATH', __DIR__);\nrequire __DIR__ . \"/Autoloader.php\"; // only in GrapheneNodeClient project\nrequire __DIR__ . '/vendor/autoload.php';\n\necho PHP_EOL . '------ start GOLOS EVENT LISTENER ------' . PHP_EOL;\n\n$db = new RedisManager();\n\n//Main process witch starts all other peocesses\n$pm = (new ProcessManager($db))\n    -\u003esetProcessName('MainProcess')\n    -\u003esetMaxRunningProcesses(3); //it is 4 total with MainProcess, MAX 512 MB RAM by default\nif ($pm-\u003ehasState()) {\n    $pm-\u003eloadState();\n} else {\n    $pm-\u003esetPriority(25)\n        -\u003esetExecutionStep(1)\n        -\u003esetMaxNTriesOfRun(0)\n        -\u003esetSecondsBetweenRuns(55)\n        -\u003esetMaxLifetimeWithoutResults(20)\n        -\u003esaveState();\n}\n\n// creating event handler\n$eh1 = (new PostIsCreatedEventHandler($db))\n    -\u003esetProcessName('GEV:votesOffafnur:1')\n    -\u003egenerateIdFromProcessName()\n    -\u003eaddCondition('op:1:voter','golosboard') //event trigger 1\n    -\u003eaddCondition('op:0','vote'); //event trigger 2\nif ($eh1-\u003ehasState()) {\n    $eh1-\u003eloadState();\n} else {\n    $eh1-\u003esetPriority(35)\n        -\u003esetExecutionStep(1)\n        -\u003esetMaxNTriesOfRun(0)\n        -\u003esetSecondsBetweenRuns(10)\n        -\u003esetMaxLifetimeWithoutResults(15)\n        -\u003esaveState();\n}\n\n// creating event handler\n$eh2 = (new PostIsCreatedEventHandler($db))\n    -\u003esetProcessName('GEV:allComments:2')\n    -\u003egenerateIdFromProcessName()\n    -\u003eaddCondition('op:0','comment'); //event trigger 1\nif ($eh2-\u003ehasState()) {\n    $eh2-\u003eloadState();\n} else {\n    $eh2-\u003esetPriority(35)\n        -\u003esetExecutionStep(1)\n        -\u003esetMaxNTriesOfRun(0)\n        -\u003esetSecondsBetweenRuns(10)\n        -\u003esetMaxLifetimeWithoutResults(15)\n        -\u003esaveState();\n}\n\n// creating event handler\n$eh3 = (new PostIsCreatedEventHandler($db))\n    -\u003esetProcessName('GEV:allVotes:3')\n    -\u003egenerateIdFromProcessName()\n    -\u003eaddCondition('op:0','vote'); //event trigger 1\nif ($eh3-\u003ehasState()) {\n    $eh3-\u003eloadState();\n} else {\n    $eh3-\u003esetPriority(35)\n        -\u003esetExecutionStep(1)\n        -\u003esetMaxNTriesOfRun(0)\n        -\u003esetSecondsBetweenRuns(10)\n        -\u003esetMaxLifetimeWithoutResults(15)\n        -\u003esaveState();\n}\n\n\n// Creating blockchain lestener\n$BEP = (new BlockchainExplorerProcess($db,ConnectorInterface::PLATFORM_GOLOS))\n    -\u003esetProcessName('GEV:BlockchainExplorer')\n    -\u003esetLastBlock(16146488)\n    -\u003eaddEvent($eh1) //do not forget add eventhandlers to explorer process\n    -\u003eaddEvent($eh2) //adding event handler for detecting events\n    -\u003eaddEvent($eh3);\nif ($BEP-\u003ehasState()) {\n    $BEP-\u003eloadState();\n} else {\n    $BEP-\u003esetPriority(30)\n        -\u003esetExecutionStep(1)\n        -\u003esetMaxNTriesOfRun(0)\n        -\u003esetSecondsBetweenRuns(30)\n        -\u003esetMaxLifetimeWithoutResults(20)\n        -\u003esaveState();\n}\n\n$pm-\u003eaddProcess($BEP)\n    -\u003eaddProcess($eh1)//add event listener for handling events\n    -\u003eaddProcess($eh2)\n    -\u003eaddProcess($eh3);\n$pm-\u003estart();\n\n```\n\nAdd this script to cron.\n\n\n#### Database manager\nLib use ready for using RedisManager from [t3ran13/php-process-manager](https://github.com/t3ran13/php-process-manager) composer package, with next DB structure:\n\n\n```\n- DB0\n    - PM:GEV:{ProcessName}:{id}:className\n    - PM:GEV:{ProcessName}:{id}:processName\n    - PM:GEV:{ProcessName}:{id}:priority\n    - PM:GEV:{ProcessName}:{id}:pid\n    - PM:GEV:{ProcessName}:{id}:executionStep\n    - PM:GEV:{ProcessName}:{id}:isRunning\n    - PM:GEV:{ProcessName}:{id}:nTriesOfRun\n    - PM:GEV:{ProcessName}:{id}:maxNTriesOfRun\n    - PM:GEV:{ProcessName}:{id}:secondsBetweenRuns\n    - PM:GEV:{ProcessName}:{id}:maxLifetimeWithoutResults\n    - PM:GEV:{ProcessName}:{id}:lastUpdateDatetime\n    - PM:GEV:{ProcessName}:{id}:data:*\n    - PM:GEV:{ProcessName}:{id}:data:events:*\n    - PM:GEV:{ProcessName}:{id}:errors:*\n    \n```\n\nHow to create onw DB manager, see [t3ran13/php-process-manager](https://github.com/t3ran13/php-process-manager)\n\n#### Events handlers\nEach Handler have to implements EventHandlerInterface and ProcessManager\\process\\ProcessInterface, you can create onw or extends from EventHandlerAbstract.\nWhen any event are found BlockchainExplorer make checking with isTrxSatisfiesConditions function and save to handling list if is it satisfied.\nWhen EventHandlerProcess starts it handle all events from queue.\n\n```php\n\u003c?php\nnamespace MyApp;\n\nuse GolosPhpEventListener\\app\\process\\handlers\\EventHandlerAbstract;\n\n\nclass VoteHandler extends EventHandlerAbstract\n{\n    public function start()\n    {\n        $events = $this-\u003egetEvents(); //TODO FIXME\n        echo PHP_EOL . date('Y-m-d H:i:s') . $this-\u003egetProcessName() . ' is running and have total events='\n            . count($events);\n\n        foreach ($events as $key =\u003e $event) {\n            // some code\n            $this-\u003esetLastUpdateDatetime(date('Y-m-d H:i:s'))\n                -\u003eremoveEventByKey($key)\n                -\u003esaveState();\n        }\n    }\n\n    /**\n     * ask process to start\n     *\n     * @return bool\n     */\n    public function isStartNeeded(): bool\n    {\n        return parent::isStartNeeded()\n            \u0026\u0026 count($this-\u003egetEvents()) \u003e 0;\n    }\n}\n```\n\n### Example\n\nExample of the app base on golos-php-event-listener you can see here https://github.com/t3ran13/golos-rating-auto-reward\n\n\n\n    \n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft3ran13%2Fgolos-php-event-listener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft3ran13%2Fgolos-php-event-listener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft3ran13%2Fgolos-php-event-listener/lists"}