{"_id":"@ativsoftware/exec-php","name":"@ativsoftware/exec-php","dist-tags":{"latest":"0.0.7"},"versions":{"0.0.7":{"name":"@ativsoftware/exec-php","version":"0.0.7","description":"Execute PHP function within NodeJS application","main":"index.js","scope":"public","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/iqbalfn/exec-php.git"},"keywords":["nodejs","javascript","php"],"author":{"name":"Iqbal Fauzi"},"license":"MIT","bugs":{"url":"https://github.com/iqbalfn/exec-php/issues"},"homepage":"https://github.com/iqbalfn/exec-php","dependencies":{"tmp":"0.0.33"},"devDependencies":{"mocha":"^9.1.3","eslint":"^8.5.0","should":"^4.0.4"},"_id":"@ativsoftware/exec-php@0.0.7","gitHead":"d5bbda3cbc4db17516a066e86ea2f0f1c3fb5cf1","_nodeVersion":"22.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-6eL28/0ehtstFLdcY5vJUNfsQyhKEGUyThNas8mSt5K0Is1vCZ0XXtp3Xj/skix8uNSwJy1KrZe4m6HBxfnZaQ==","shasum":"2e553e7e841ad6c6d91f8af59566eeff69f95149","tarball":"https://registry.npmjs.org/@ativsoftware/exec-php/-/exec-php-0.0.7.tgz","fileCount":7,"unpackedSize":10523,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCID8tq7TLMV3h0WCukZq6rTjTXcYk3R4U4wlKXXaT3X77AiEA4Erv/yOQZWwhk+rWTSxzv61BQRHW3M9IsFyzMQoTcBU="}]},"_npmUser":{"name":"nathanaela","email":"nathan@master-technology.com"},"directories":{},"maintainers":[{"name":"nathanaela","email":"nathan@master-technology.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/exec-php_0.0.7_1768254875612_0.6233583444610293"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-12T21:54:35.506Z","0.0.7":"2026-01-12T21:54:35.754Z","modified":"2026-01-12T21:54:36.077Z"},"maintainers":[{"name":"nathanaela","email":"nathan@master-technology.com"}],"description":"Execute PHP function within NodeJS application","homepage":"https://github.com/iqbalfn/exec-php","keywords":["nodejs","javascript","php"],"repository":{"type":"git","url":"git+https://github.com/iqbalfn/exec-php.git"},"author":{"name":"Iqbal Fauzi"},"bugs":{"url":"https://github.com/iqbalfn/exec-php/issues"},"license":"MIT","readme":"# exec-php\n\nExecute PHP function within NodeJS application\n\n## Installation\n\n```bash\nnpm install exec-php\n```\n\n## Usage\n\n```js\nlet execPhp = require('exec-php');\n\nexecPhp('path/to/file.php', '/usr/bin/php', (err, php, out) => {\n    // the `php` argument is now contains all php defined functions\n    php.my_func(arg1, arg2, (err, res, out, print) => {\n        // `res` argument is now hold the returned value of `my_func` php function\n        // `print` hold anything that get printed during calling the `my_func` function\n    })\n})\n```\n\n## Arguments\n\n1. `phpfile::string` Path to user php file.\n1. `phpbin::string` Path to engine php binary file.\n1. `callback::function` A function to call after populating the php functions.\n\nThe `callback` function will be called with below arguments:\n\n1. `error::mixed` The error message.\n1. `php::object` The php object that hold all php defined functions.\n1. `printed::string` All printed string while populating php functions.\n\n## php Arguments\n\nAll user defined function on php engine will be appended to `php` argument of\nthe caller. The function will be **lower case**. You can now call the function\nnormally with additional last argument is the callback function to get response\nof the php functions call with below arguments:\n\n1. `error::mixed` Error message\n1. `result::mixed` Returned content of user php function\n1. `output::string` Printed string on requiring the php file.\n1. `printed::string` Printed string on calling user php function.\n\n## Example\n\n```php\n// file.php\n<?php\n\necho \"One\";\nfunction my_function($arg1, $arg2){\n    echo \"Two\";\n    return $arg1 + $arg2;\n}\n```\n\n```js\n// app.js\nlet execPhp = require('exec-php');\n\nexecPhp('file.php', (err, php, out) => {\n    // outprint is now `One'.\n\n    php.my_function(1, 2, (err, result, output, printed) => {\n        // result is now `3'\n        // output is now `One'.\n        // printed is now `Two'.\n    })\n})\n```\n\n## Note\n\nAll uppercase function name on PHP will be converted to lowercase on `exec-php`.\n\n```php\n// file.php\n<?php\n\nfunction MyFunction($a, $b){\n    return $a + $b;\n}\n```\n\n```js\n// app.js\nlet execPhp = require('exec-php')\n\nexecPhp('file.php', (err, php, out) => {\n    php.myfunction(1, 2, function(error, result){\n        // result is now 3\n    })\n})\n```\n\n## ChangeLog\n\n1. 0.0.3\n    1. Handle PHP throw error exception\n1. 0.0.4\n    1. Upgrade tmp module to suppress opsolete functions ( [GuilhermeReda](https://github.com/GuilhermeReda) )\n    1. Add `noop` function to support the new node callback standard\n1. 0.0.5\n    1. Close temp file pointer on removing the file ( [MHDMAM](https://github.com/MHDMAM) )\n1. 0.0.6\n    1. Remove deprecated `module.parent` ( [Jakub Zasański](https://github.com/jakubzasanski) )\n    1. Upgrade deprecated dependencies\n1. 0.0.7\n    1. Upgrade tmp module to version 0.2.5\n    1. Use JSON_INVALID_UTF8_SUBSTITUTE and JSON_UNESCAPED_UNICODE for JSON encoding\n","readmeFilename":"README.md","_rev":"1-b95553c0f0cba1cca523a267f8a009fe"}