{"id":22128951,"url":"https://github.com/ddmitov/elephant-harness","last_synced_at":"2026-04-28T16:03:29.438Z","repository":{"id":57222287,"uuid":"66847230","full_name":"ddmitov/elephant-harness","owner":"ddmitov","description":"Node.js - Electron - NW.js controller for PHP scripts :elephant:","archived":false,"fork":false,"pushed_at":"2021-09-26T16:45:18.000Z","size":81,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-28T07:24:04.639Z","etag":null,"topics":["electron","elephant-harness","node-js","nodejs-module","nwjs","php"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/elephant-harness","language":"JavaScript","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/ddmitov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-29T13:43:21.000Z","updated_at":"2024-12-25T23:50:29.000Z","dependencies_parsed_at":"2022-08-29T04:10:12.206Z","dependency_job_id":null,"html_url":"https://github.com/ddmitov/elephant-harness","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/ddmitov/elephant-harness","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddmitov%2Felephant-harness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddmitov%2Felephant-harness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddmitov%2Felephant-harness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddmitov%2Felephant-harness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddmitov","download_url":"https://codeload.github.com/ddmitov/elephant-harness/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddmitov%2Felephant-harness/sbom","scorecard":{"id":330282,"data":{"date":"2025-08-11","repo":{"name":"github.com/ddmitov/elephant-harness","commit":"6816010abde32b5c9a81732f4c6c1c223963ab4e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T03:23:55.325Z","repository_id":57222287,"created_at":"2025-08-18T03:23:55.325Z","updated_at":"2025-08-18T03:23:55.325Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32387923,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"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":["electron","elephant-harness","node-js","nodejs-module","nwjs","php"],"created_at":"2024-12-01T17:57:24.312Z","updated_at":"2026-04-28T16:03:29.419Z","avatar_url":"https://github.com/ddmitov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# elephant-harness\n\n[![Travis CI Build Status](https://travis-ci.org/ddmitov/elephant-harness.svg?branch=master)](https://travis-ci.org/ddmitov/elephant-harness)\n[![Snyk Status](https://snyk.io/test/github/ddmitov/elephant-harness/badge.svg)](https://snyk.io/test/github/ddmitov/elephant-harness)\n[![Maintainability](https://api.codeclimate.com/v1/badges/f728110055011b195a4d/maintainability)](https://codeclimate.com/github/ddmitov/elephant-harness/maintainability)\n\n[Node.js](http://nodejs.org/) - [Electron](http://electron.atom.io/) - [NW.js](http://nwjs.io/) package for asynchronous handling of [PHP](http://php.net/) scripts\n\n## Quick Start\n\n``npm install elephant-harness``  \n\n```javascript\nconst elephantHarness = require(\"elephant-harness\");\n\nlet phpTest = {};\nphpTest.script = \"/test/test.php\";\n\nphpTest.stdoutFunction = function (stdout) {\n  console.log(stdout);\n};\n\nelephantHarness.startScript(phpTest);\n```\n\n## Core Dependency\n\n``child_process``\n\n## External Dependency\n\nThe only external dependency of elephant-harness is a PHP interpreter on PATH or  \na PHP interpreter identified by its full pathname.  \n\nelephant-harness npm package test will fail if no ``php`` binary is available on PATH.  \n\n``php`` binary should be used in [Node.js](http://nodejs.org/) applications and test scripts.  \n\n``php-cgi`` binary should be used in [Electron](http://electron.atom.io/) and [NW.js](http://nwjs.io/) applications.\n\n## API\n\nAll settings of a PHP script executed by elephant-harness are stored in a JavaScript object with an arbitrary name and the following object properties:  \n\n* **script**  \n  ``String`` for PHP script full path  \n  *This object property is mandatory.*  \n\n  ```javascript\n  phpTest.script = \"/full/path/to/test.php\";\n  ```\n\n* **stdoutFunction**  \n  will be executed every time data is available on STDOUT  \n  The only parameter passed to the ``stdoutFunction`` is the STDOUT ``String``.  \n\n  ```javascript\n  phpTest.stdoutFunction = function (stdout) {\n    document.getElementById(\"DOM-element-id\").textContent = stdout;\n  };\n  ```\n\n* **stderrFunction**  \n  will be executed every time data is available on STDERR  \n  The only parameter passed to the ``stderrFunction`` is the STDERR ``String``.  \n\n  ```javascript\n  phpTest.stderrFunction = function (stderr) {\n    console.log(\"PHP script STDERR:\\n\");\n    console.log(stderr);\n  };\n  ```\n\n* **errorFunction**  \n  will be executed on PHP script error  \n  The only parameter passed to the ``errorFunction`` is the error ``Object``.  \n\n  The ``errorFunction`` can generate a message when PHP interpreter is not found:  \n\n  ```javascript\n  phpTest.errorFunction = function (error) {\n    if (error.code === \"ENOENT\") {\n      console.log(\"PHP interpreter was not found.\");\n    }\n  };\n  ```\n\n* **exitFunction**  \n  will be executed when PHP script has ended  \n  The only parameter passed to the ``exitFunction`` is the exit code ``String``.  \n\n  The ``exitFunction`` can generate a message when PHP script is not found:  \n\n  ```javascript\n  phpTest.exitFunction = function (exitCode) {\n    if (exitCode === 2) {\n      console.log(\"PHP script was not found.\");\n    }\n  };\n  ```\n\n* **phpInterpreter**  \n  ``String`` for a PHP interpreter: either filename on PATH or full pathname  \n  If no ``phpInterpreter`` is defined, ``php`` binary on PATH is used, if available.  \n\n  ```javascript\n  phpTest.interpreter = \"/full/path/to/php\";\n  ```\n\n* **interpreterSwitches**  \n  ``Array`` for PHP interpreter switches  \n\n  ```javascript\n  phpTest.interpreterSwitches = [];\n  phpTest.interpreterSwitches.push(\"-q\");\n  ```\n\n  The ``php-cgi`` binary should be used with the ``-q`` switch in Electron and NW.js  \n  to enable quiet mode and suppress unnecessary HTTP header output.  \n\n* **scriptArguments**  \n  ``Array`` for PHP script arguments  \n\n  ```javascript\n  phpTest.scriptArguments = [];\n  phpTest.scriptArguments.push(\"argument-one\");\n  phpTest.scriptArguments.push(\"argument-two\");\n  ```\n\n* **options**  \n  ``Object`` for PHP script options passed to the ``child_process`` core module.  \n  Click [here](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) for a full list of all available ``child_process`` options.\n\n* **options.cwd**  \n  ``String`` for a new PHP script current working directory  \n\n  ```javascript\n  phpTest.options = {};\n  phpTest.options.cwd = \"/full/path/to/current-working-directory\";;\n  ```\n\n* **options.env**  \n  ``Object`` for a new PHP script environment  \n\n  Script environment with an inherited PATH and a new variable:  \n\n  ```javascript\n  phpTest.options = {};\n  phpTest.options.env = {};\n  phpTest.options.env.PATH = process.env.PATH;\n  phpTest.options.env.TEST = \"test\";\n  ```\n\n* **options.detached**  \n  ``Boolean`` option for starting detached PHP processes like servers  \n\n  ``options.detached`` must be set to ``true`` and  \n  ``options.stdio`` must be set to ``\"ignore\"`` to  \n  start a detached process without receiving anything from it.  \n  A process detached with the above options can run even after its parent has ended.  \n\n  Example settings for a PHP server application:  \n\n  ```javascript\n  let phpServer = {};\n  phpServer.script = \"/path/to/php-server-application\";\n\n  phpServer.options = {};\n  phpServer.options.detached = true;\n  phpServer.options.stdio = \"ignore\";\n\n  const elephantHarness = require(\"elephant-harness\");\n  elephantHarness.startScript(phpServer);\n\n  phpServer.scriptHandler.unref();\n  ```\n\n* **requestMethod**  \n  ``String`` holding either ``GET`` or ``POST`` as a value.  \n  ``requestMethod`` has to be set for PHP scripts reading input data in CGI mode.\n\n  ```javascript\n  phpTest.requestMethod = \"GET\";\n  ```\n\n  or\n\n  ```javascript\n  phpTest.requestMethod = \"POST\";\n  ```\n\n* **inputData**  \n  ``String`` or ``Function`` supplying user data as its return value.  \n\n  Single HTML input box example with no dependencies:  \n\n  ```javascript\n  phpTest.inputData = function () {\n    let data = document.getElementById(\"input-box-id\").value;\n    return data;\n  }\n  ```\n\n  Whole HTML form example based on [jQuery](https://jquery.com/):  \n\n  ```javascript\n  phpTest.inputData = function () {\n    let formData = $(\"#form-id\").serialize();\n    return formData;\n  }\n  ```\n\n## Interactive Scripts\n\nelephant-harness can also start and communicate with interactive scripts having their own event loops and capable of repeatedly receiving STDIN input. Use the following code to send data to an interactive script waiting for input on STDIN:\n\n```javascript\nlet data = document.getElementById(\"interactive-script-input\").value;\nphpTest.scriptHandler.stdin.write(data);\n```\n\n## [Electron Demo](https://www.npmjs.com/package/elephant-harness-demo-electron)\n\n## [NW.js Demo](https://www.npmjs.com/package/elephant-harness-demo-nwjs)\n\n## [Credits](./CREDITS.md)\n\n## [License](./LICENSE.md)\n\nMIT 2016 - 2018  \nDimitar D. Mitov  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddmitov%2Felephant-harness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddmitov%2Felephant-harness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddmitov%2Felephant-harness/lists"}