{"id":16049990,"url":"https://github.com/codad5/php-inex","last_synced_at":"2026-04-18T04:02:14.096Z","repository":{"id":62289201,"uuid":"557460238","full_name":"codad5/php-inex","owner":"codad5","description":"Simulating Node.js require in php","archived":false,"fork":false,"pushed_at":"2022-12-05T01:48:16.000Z","size":40,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-12T15:41:23.687Z","etag":null,"topics":["node-js","php","php-library"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codad5.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-25T18:22:09.000Z","updated_at":"2022-12-05T01:28:08.000Z","dependencies_parsed_at":"2023-01-22T22:55:13.880Z","dependency_job_id":null,"html_url":"https://github.com/codad5/php-inex","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/codad5/php-inex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codad5%2Fphp-inex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codad5%2Fphp-inex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codad5%2Fphp-inex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codad5%2Fphp-inex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codad5","download_url":"https://codeload.github.com/codad5/php-inex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codad5%2Fphp-inex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31955919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["node-js","php","php-library"],"created_at":"2024-10-09T00:41:39.600Z","updated_at":"2026-04-18T04:02:14.062Z","avatar_url":"https://github.com/codad5.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP IMPORTER\r\n\r\nThis is a package that simulates node.js import feature.\r\n\r\n## Installing it \r\n```\r\ncomposer require codad5/php-inex\r\n```\r\n## SAMPLE FOR DEFAULT EXPORT\r\n\r\n##### Exporting data\r\n\r\n- Export.js\r\n\r\n    ```js\r\n    export default const greet = () =\u003e {\r\n        console.log('hello')\r\n    }\r\n    ```\r\n\r\n- Export.php\r\n\r\n    ```php\r\n    \u003c?php\r\n    $export = function(){\r\n        echo \"hello\";\r\n    }\r\n    ```\r\n\r\n##### Importing Data\r\n\r\n- Import.js\r\n\r\n    ```js\r\n    const greeting = require('Export')\r\n    greeting(); // hello\r\n    ```\r\n\r\n- Import.php\r\n\r\n    ```php\r\n    \u003c?php\r\n        require __DIR__.'/vendor/autoload.php';\r\n        use Codad5\\PhpInex\\Import;\r\n        $greeting = Import::this('Export');\r\n        $greeting(); // hello\r\n    ```\r\n\r\n\r\n## SAMPLE FOR MULTIPLE EXPORT\r\n\r\n##### Exporting data\r\n\r\n- Export.js\r\n\r\n    ```js\r\n    const greet = () =\u003e {\r\n        console.log('hello')\r\n    }\r\n    const sum = (a, b) =\u003e {\r\n         return a + b\r\n    }\r\n    export {greet, sum}\r\n    ```\r\n\r\n- Export.php\r\n\r\n    ```php\r\n    \u003c?php\r\n    $export['greet'] = function(){\r\n        echo \"hello\";\r\n    }\r\n\r\n    $export['sum'] = function($a, $b){\r\n        return $a + $b;\r\n    }\r\n    ```\r\n\r\n##### Importing Data\r\n\r\n- Import.js\r\n\r\n    ```js\r\n    const {greet, sum} = require('Export')\r\n    greet();\r\n    console.log(sum(2,4)) // 6\r\n    ```\r\n\r\n- Import.php\r\n\r\n    ```php\r\n    \u003c?php\r\n        require __DIR__.'/vendor/autoload.php';\r\n        use Codad5\\PhpInex\\Import;\r\n        [\"greet\" =\u003e $greet, \"sum\" =\u003e $sum] = Import::this('Export');\r\n        $greet(); // hello\r\n        echo $sum(2,4) // 6\r\n    ```\r\n\r\n## USING ROUTER LIBRARY\r\n\r\n- For php we will use [TrulyAo php-router](https://github.com/aosasona/php-router)\r\n- For Node.js we will use Express.js\r\n\r\n##### Exporting routes\r\n\r\n- `routes/api.js`\r\n\r\n    ```js\r\n    const route = require('express').Router()\r\n\r\n    route.get('/food', (req, res) =\u003e {\r\n        res.json({\r\n            'name' : \"rice\"\r\n        })\r\n    })\r\n\r\n    export default route\r\n    ```\r\n\r\n- `routes/api.php`\r\n\r\n    ```php\r\n    \u003c?php\r\n    require __DIR__.'/vendor/autoload.php';\r\n    use \\Trulyao\\PhpRouter\\Router as Router;\r\n    $route = new Router();\r\n    $route-\u003eget('/food', function($req, $res){\r\n        $res-\u003ejson([\r\n            'name' =\u003e \"rice\"\r\n            ]);\r\n    });\r\n    $export = $route;\r\n    ```\r\n\r\n##### Importing routes\r\n\r\n- Import.js\r\n\r\n    ```js\r\n    const app = require('express')();\r\n    const apiRoute = require('routes/api')\r\n\r\n    app.get('', (req, res) =\u003e {\r\n        res.send('welcome')\r\n    })\r\n    app.use('/api', apiRoute)\r\n    \r\n    // serving the application\r\n    app.listen(4000)\r\n    \r\n    ```\r\n\r\n- Import.php\r\n\r\n    ```php\r\n    \u003c?php\r\n    require __DIR__.'/vendor/autoload.php';\r\n    use \\Trulyao\\PhpRouter\\Router as Router;\r\n    use Codad5\\PhpInex\\Import;\r\n\r\n    $route = new Router();\r\n    $apiRoute = Import::this('routes/api');\r\n    \r\n    $route-\u003eget('/', function($req, $res){\r\n        $res-\u003esend('welcome');\r\n    });\r\n    $route-\u003eset_route('/api', $apiRoute);\r\n    \r\n    // serving the application\r\n    $route-\u003eserve();\r\n    ```\r\n\r\n### More \r\nYou can also import non php files but you get their file content instead\r\n\r\n### Coming soon\r\n- Formatted json import\r\n\r\n\u003e Built with 🧡 by [Aniezeofor Chibueze](https://github.com/codad5)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodad5%2Fphp-inex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodad5%2Fphp-inex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodad5%2Fphp-inex/lists"}