{"id":15412926,"url":"https://github.com/ascorbic/use-php","last_synced_at":"2025-07-29T05:32:36.596Z","repository":{"id":56710558,"uuid":"523360641","full_name":"ascorbic/use-php","owner":"ascorbic","description":"Use PHP in React","archived":false,"fork":false,"pushed_at":"2023-11-07T07:26:38.000Z","size":4296,"stargazers_count":206,"open_issues_count":1,"forks_count":6,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-08T01:42:53.204Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://use-php.netlify.app","language":"TypeScript","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/ascorbic.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}},"created_at":"2022-08-10T13:45:37.000Z","updated_at":"2025-04-03T16:34:34.000Z","dependencies_parsed_at":"2024-10-21T13:54:58.756Z","dependency_job_id":null,"html_url":"https://github.com/ascorbic/use-php","commit_stats":{"total_commits":17,"total_committers":3,"mean_commits":5.666666666666667,"dds":"0.17647058823529416","last_synced_commit":"d71451031ee5d37131b68fcbfe0e468202a58d18"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ascorbic/use-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ascorbic%2Fuse-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ascorbic%2Fuse-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ascorbic%2Fuse-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ascorbic%2Fuse-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ascorbic","download_url":"https://codeload.github.com/ascorbic/use-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ascorbic%2Fuse-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267633670,"owners_count":24118777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"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":[],"created_at":"2024-10-01T16:54:51.318Z","updated_at":"2025-07-29T05:32:36.545Z","avatar_url":"https://github.com/ascorbic.png","language":"TypeScript","readme":"![a blue Lambourghini with the licence \"USEPHP\"](https://github.com/ascorbic/use-php/assets/213306/3f019612-2a81-447a-9f52-f9125f4c4a1b)\n\n# 🏎️ usePHP 💨\n\nA React hook for running PHP? Why not?\n\nIt runs in a Netlify Edge Function and uses [php-wasm](https://github.com/seanmorris/php-wasm) to execute the PHP. It runs asynchronously, so you need a renderer that supports async components.\n\n**[View the demo](https://php-edge.netlify.app/)**\n\n[![deploy to netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ascorbic/use-php)\n\n### Usage\n\n```tsx filename=netlify/edge-functions/php.tsx\n/** @jsx h */\nimport { h, renderToString } from \"https://deno.land/x/jsx/mod.ts\";\nimport { usePHP } from \"https://deno.land/x/use_php/mod.ts\";\n\nexport default async function handler(request: Request) {\n  const php = await usePHP(request, h);\n  return new Response(\n    await renderToString(\n      \u003chtml\u003e\n        \u003chead\u003e\n          \u003ctitle\u003eUse PHP\u003c/title\u003e\n        \u003c/head\u003e\n        \u003cbody\u003e\n          {await php`\n              \u003c?php phpinfo(); ?\u003e\n          `}\n        \u003c/body\u003e\n      \u003c/html\u003e\n    ),\n    {\n      headers: {\n        \"content-type\": \"text/html; charset=UTF-8\",\n      },\n    }\n  );\n}\n\nexport const config = {\n  path: \"/*\",\n  excluded_paths: \"/public/*\",\n};\n```\n\n## API\n\n### `usePHP(request: Request, renderer?: JSXRenderer)`\n\nPass in the request object and an optional JSX renderer and it will return tagged template that you can use to execute PHP. If you pass a JSX render function to the hook (e.g. `h` or `React.createElement`), then the template will return a JSX element. If you omit the renderer it will return an HTML string instead.\n\nTry it yourself:\n\n[![deploy to netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/ascorbic/use-php)\n\n## FAQ\n\n- **Why?**\n  - Why not? That Lambo won't buy itself.\n- **How can I deploy this to production?**\n  - 🤦🏻‍♂️ \n\n### LICENCE\n\nMIT Licence. © 2023 [Matt Kane](https://github.com/ascorbic)\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fascorbic%2Fuse-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fascorbic%2Fuse-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fascorbic%2Fuse-php/lists"}