{"id":28424147,"url":"https://github.com/scrawler-labs/php2js","last_synced_at":"2026-04-27T18:35:12.344Z","repository":{"id":62541362,"uuid":"370132537","full_name":"scrawler-labs/php2js","owner":"scrawler-labs","description":"Convert php code to javascript code that run on browser [Experimental] ","archived":false,"fork":false,"pushed_at":"2023-12-15T02:54:30.000Z","size":23,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-02T22:17:36.327Z","etag":null,"topics":["compiler","javascript","php","php2js"],"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/scrawler-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-23T18:48:21.000Z","updated_at":"2023-12-11T22:45:28.000Z","dependencies_parsed_at":"2025-06-25T01:38:42.783Z","dependency_job_id":"87765ead-488e-4c76-8120-a11acf0590a7","html_url":"https://github.com/scrawler-labs/php2js","commit_stats":null,"previous_names":["scrawler-labs/php2js"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/scrawler-labs/php2js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrawler-labs%2Fphp2js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrawler-labs%2Fphp2js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrawler-labs%2Fphp2js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrawler-labs%2Fphp2js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scrawler-labs","download_url":"https://codeload.github.com/scrawler-labs/php2js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scrawler-labs%2Fphp2js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32349913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T17:12:42.749Z","status":"ssl_error","status_checked_at":"2026-04-27T17:12:41.658Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["compiler","javascript","php","php2js"],"created_at":"2025-06-05T09:36:40.599Z","updated_at":"2026-04-27T18:35:12.325Z","avatar_url":"https://github.com/scrawler-labs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP2JS\nConvert php code to javascript code that can run on browser\n\n### Installation \npackage can be installed via composer\u003cbr\u003e\n```\ncomposer require piqon/php2js\n```\n\n### Usage\nIf You want to create a copiled javascript file , you can run the following code: \u003cbr\u003e\n\n```php\n\u003c?php\ninclude __DIR__ . '/vendor/autoload.php';\n\n/*\n* Replace test.php with path of your input php file\n* Replace test.js with path for your js file output\n*/\n\n\\PHP2JS\\PHP2JS::compileFile(__DIR__.'/test.php',__DIR__.'/test.js');\n```\n\nIf you just want to convert a small block of code , you can run the following code:\n\n```php\n\u003c?php\ninclude __DIR__ . '/vendor/autoload.php';\n\n$code = \"\n$name='1';\necho 'hi'; \n\"\n\n\\PHP2JS\\PHP2JS::compile($code);\n```\n\n### Demo\n\nInput code :\n\n```php\n\u003c?php\n$name = 'Pranjal';\n$cars = ['BMW','Audi'];\n$cars-\u003epush('Ferrari');\necho $name;\necho $cars;\n\nfunction click(){\n    echo 'button clicked!';\n}\n```\n\nOutput code:\n```javascript\n\nlet name = 'Pranjal';\nlet cars = ['BMW', 'Audi'];\ncars.push('Ferrari');\nconsole.log( name);\nconsole.log( cars);\n\nfunction click()\n{\n    console.log( 'button clicked!');\n}\n\n```\n\n\n### Note\nThis was designed to convert php scripts to javascript code , this might not work with full blown php classes !\nYou can call javascript functions like console.log etc right from your php code and it will work as expected in the browser.\nThis compiler does not support magic variables and magic functions of PHP.\n\n\n### Changelog\n\n#### v0.3.0\n- Added support for import : `include 'test'` now converts to `import test from './test.js'`\nYou can also use import_from() php function to define path of module.\nExample:\n```php\nimport_from('test','./component/test.js');\n```\nwill compile to \n```js\nimport test from './component/test.js';\n```\n\u003cbr\u003e\n\n- Added support for async function declaration via comment:\n```php\n// @async\nfunction abc(){\nreturn 'hi';\n}\n```\nwill compile to \n```js\nasync function abc(){\nreturn 'hi';\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrawler-labs%2Fphp2js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscrawler-labs%2Fphp2js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrawler-labs%2Fphp2js/lists"}