{"id":22400405,"url":"https://github.com/bearsunday/bear.reactjsmodule","last_synced_at":"2025-06-14T02:32:55.373Z","repository":{"id":62492640,"uuid":"59724075","full_name":"bearsunday/BEAR.ReactJsModule","owner":"bearsunday","description":"DEPRECATED","archived":false,"fork":false,"pushed_at":"2017-01-26T18:57:59.000Z","size":1336,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"1.x","last_synced_at":"2024-05-02T19:16:16.508Z","etag":null,"topics":["deprecated"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bearsunday.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}},"created_at":"2016-05-26T06:01:30.000Z","updated_at":"2018-02-14T05:26:44.000Z","dependencies_parsed_at":"2022-11-02T11:30:38.984Z","dependency_job_id":null,"html_url":"https://github.com/bearsunday/BEAR.ReactJsModule","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearsunday%2FBEAR.ReactJsModule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearsunday%2FBEAR.ReactJsModule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearsunday%2FBEAR.ReactJsModule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bearsunday%2FBEAR.ReactJsModule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bearsunday","download_url":"https://codeload.github.com/bearsunday/BEAR.ReactJsModule/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228257833,"owners_count":17892652,"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":["deprecated"],"created_at":"2024-12-05T08:12:53.566Z","updated_at":"2024-12-05T08:12:54.487Z","avatar_url":"https://github.com/bearsunday.png","language":"PHP","readme":"# BEAR.ReactJsModule\n\n**BEAR.ReactJsModule** is a `redux-react-ssr` which renders Redux React UI on the server-side support module for BEAR.Sunday.\n\n\n## Prerequisites\n\n * php7\n * [V8Js](http://php.net/v8js)\n\n## Install\n\n### Composer Install\n\n```\ncomposer require bear/reactjs-module\n```\n\n### Module Install\n\n```php\n$distDir = dirname(__DIR__, 2) . '/var/www/dist';\n$this-\u003einstall(new ReduxModule($distDir, 'ssr_app');\n```\n\nIn this canse, you need to place `ssr-app.bundle.js` at `$baseDir` directory.\n\n### Redux UI Skeleton Install \n\nCopy skeleton directory to your BEAR.Sunday project root.\n\n```\ncp -r vendor/bear/reactjs-module/ui-skeleton/redux/ui .\ncp vendor/bear/reactjs-module/ui-skeleton/redux/package.json .\n```\n\nInstall dependencies.\n\n```\nyarn install\n```\n\nBuild ui application.\n\n```\nyarn run build\n```\n\nThree js bundled file is produced.\n \n * react.bundle.js React library bundled code\n * {app-name}.bundle.js Application bundled code for client side\n * {ssr-app-name}.bundle.js Application bundled code for server side \n \nYou can include JavaScript client code (CSS, DOM ..) for `{app}.bundle.js` only. See more detail at the [example](https://github.com/bearsunday/BEAR.ReactJsModule/tree/1.x/docs/demo/ui/webpack.config.js#L7-L9).\n\n\n\n### ResourceOjbect\n\nTo inject SSR renderer, Annotate `@Inject` with `@Named` annotation to `setRenderer` setter method\nwith `{ssr-app-name}` application name.\n\n\n```php\n\nuse BEAR\\Resource\\RenderInterface;\nuse BEAR\\Resource\\ResourceObject;\nuse Ray\\Di\\Di\\Inject;\nuse Ray\\Di\\Di\\Named;\n\nclass Greeting extends ResourceObject\n{\n    /**\n     * @Inject\n     * @Named(\"ssr_app\")\n     */\n    public function setRenderer(RenderInterface $renderer)\n    {\n        $this-\u003erenderer = $renderer;\n    }\n\n    public function onGet()\n    {\n        $this-\u003ebody = [\n            'title' =\u003e 'Greeting',\n            'hello' =\u003e ['message' =\u003e 'konichiwa']\n        ];\n\n        return $this;\n    }\n}\n\n    \n```\n\n### Template\n\nWe need php template code. For exapmle, `Index.php` page resource needs `Index.html.php` template file.\nYou can get the value of body by `escape()` or `raw()`.\n\n```php\n\u003c?php\n\n/* @var $ssr \\BEAR\\ReactJsModule\\Ssr */\n$view = $ssr-\u003erender(['hello']);\n\nreturn \u003c\u003c\u003c\"EOT\"\n\u003c!doctype\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003e{$ssr-\u003eescape('title')}\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cdiv id=\"root\"\u003e{$view-\u003emarkup}\u003c/div\u003e\n\u003cscript src=\"build/react.bundle.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"build/app.bundle.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e{$view-\u003ejs}\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\nEOT;\n\n```\n\nNote: `app.bundle.js` is client javascript code. The page is rendered fully even {$markup} is removed by client JS code.\n\n### VoidV8Module\n\nIt is possible to install `VoidV8Module` to run non V8Js environment for clien side rendering only.\n\n```php\n$this-\u003einstall(new FakeV8Module(new ReduxModule($distDir, 'ssr_hello')));\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbearsunday%2Fbear.reactjsmodule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbearsunday%2Fbear.reactjsmodule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbearsunday%2Fbear.reactjsmodule/lists"}