{"id":21474934,"url":"https://github.com/wayfair/hypernova-php","last_synced_at":"2025-05-16T10:06:14.139Z","repository":{"id":37588123,"uuid":"79125319","full_name":"wayfair/hypernova-php","owner":"wayfair","description":"PHP client for rendering your React components via Hypernova.","archived":false,"fork":false,"pushed_at":"2024-11-27T20:19:07.000Z","size":93,"stargazers_count":76,"open_issues_count":6,"forks_count":21,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-19T12:42:32.737Z","etag":null,"topics":["hacktoberfest","hypernova","hypernova-php","react"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wayfair.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-01-16T14:16:24.000Z","updated_at":"2022-12-12T16:07:33.000Z","dependencies_parsed_at":"2024-12-03T17:53:54.541Z","dependency_job_id":"85fcddbb-32e8-4b4a-8f7b-7becf0ff13bb","html_url":"https://github.com/wayfair/hypernova-php","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayfair%2Fhypernova-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayfair%2Fhypernova-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayfair%2Fhypernova-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayfair%2Fhypernova-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wayfair","download_url":"https://codeload.github.com/wayfair/hypernova-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509477,"owners_count":22082891,"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","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":["hacktoberfest","hypernova","hypernova-php","react"],"created_at":"2024-11-23T10:35:17.993Z","updated_at":"2025-05-16T10:06:14.101Z","avatar_url":"https://github.com/wayfair.png","language":"PHP","readme":"# Hypernova-PHP [![Build Status](https://travis-ci.org/wayfair/hypernova-php.svg?branch=master)](https://travis-ci.org/wayfair/hypernova-php) \n\n\u003e PHP client for your [Hypernova service](https://github.com/airbnb/hypernova).\n\n## Why Hypernova?\n\nThe broader question tends to be \"how do I Server-Side Render my React app?\"  You may have this as a business requirement (e.g. SEO) or just want to give users the fastest initial render possible.\n\nAssuming you have a PHP backend (why are you here, otherwise?), generally you will want to stand up a node.js service to do the rendering for you.  You could _try_ [phpv8js](https://github.com/phpv8/v8js) but I believe it is contraindicated for production use at any scale.  That's just my opinion, do your own research :grin:\n\nSo then - write your own node.js service, or use one off the shelf.  Writing your own node.js service isn't terrifically hard - you could reasonably stand up a thing that would render react components for you in ~20 lines of code.  We personally went with hypernova because it's lightweight, pluggable (see the plugin system), performant (see the clever bytecode caching in `createVM`), and has nice client-side fallback behavior in case the service has issues.\n\n## Getting Started\n\n`composer require wayfair/hypernova-php`\n\nMake a `Renderer`:\n\n```\nuse \\WF\\Hypernova\\Renderer;\n\n$renderer = new Renderer('http://localhost:3030/batch');\n```\n\nGive it some work:\n\n```\n$renderer-\u003eaddJob('myViewId', ['name' =\u003e 'my_module_name', 'data' =\u003e ['some' =\u003e ['props']]]);\n```\n\nOptionally add a plugin or two (see plugin section):\n\n```\n$renderer-\u003eaddPlugin($myPlugin);\n$renderer-\u003eaddPlugin($myOtherPlugin);\n```\n\nThen go get your rendered `Response`:\n\n```\n$response = $renderer-\u003erender();\n\necho $response-\u003eresults['myViewId']-\u003ehtml;\n```\n\n## Plugin API\n\nThis is how you customize client behavior.  Common usecases include:\n\n* Logging request metadata like performance timings\n* Error logging\n* Injecting/removing props\n* Inlining stack traces in development environments\n* Stopping requests to the service entirely, letting everything fall back to client rendering\n\nGenerally, you will want to implement some subset of the lifecycle hooks; maybe you\nwant `onError` handling but have no need for `shouldSendRequest`.  For \ndeveloper convenience, you may extend `\\WF\\Hypernova\\Plugin\\BasePlugin` which\nprovides no-op implementations of all of the hooks.\n\nSee the [js client docs](https://github.com/airbnb/hypernova-node#plugin-lifecycle-api) for full descriptions of the available hooks.\n\n#### Contributing:\n\nFork it, submit a PR.\n\n#### Run tests:\n\n`composer test`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwayfair%2Fhypernova-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwayfair%2Fhypernova-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwayfair%2Fhypernova-php/lists"}