https://github.com/slogsdon/php-web-component-ssr
Provides server-side rendering support for native web components / custom elements
https://github.com/slogsdon/php-web-component-ssr
server-side-rendering web-components
Last synced: 16 days ago
JSON representation
Provides server-side rendering support for native web components / custom elements
- Host: GitHub
- URL: https://github.com/slogsdon/php-web-component-ssr
- Owner: slogsdon
- License: mit
- Created: 2019-03-26T07:26:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-06T05:21:26.000Z (over 5 years ago)
- Last Synced: 2025-04-13T00:34:08.043Z (16 days ago)
- Topics: server-side-rendering, web-components
- Language: PHP
- Homepage: https://packagist.org/packages/slogsdon/web-component-ssr
- Size: 26.4 KB
- Stars: 17
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# web-component-ssr
> Provides server-side rendering support for native web components / custom elements
### Features
- Plain PHP and JavaScript
- Native [web components](https://developer.mozilla.org/en-US/docs/Web/Web_Components)
- Minimal dependencies### Reasoning
PHP is easy to install, if not already present on you computer. PHP runs pretty much everywhere. PHP is flexible.
JavaScript is in a similar boat. It's readily available and flexible. Modern browser JavaScript is more than capable.
This project also scratches an itch to see how much PHP and JavaScript can work together to handle this problem domain.
## Requirements
- [PHP 7.1+](http://www.php.net/)
- [Composer](https://getcomposer.org/) (for PHP autoloader only)
- [`web-component-hydration`](https://www.npmjs.com/package/web-component-hydration)## Running the demo
```
cd examples/simple && yarn install
cd ../.. && composer start
```This will install a local copy of `web-component-hydration` and call the `start` Composer script defined in `composer.json` and execute the built-in PHP server.
On page load, PHP will output a template file as HTML. It will also prepare the client-side template. Once the DOM has loaded, the JavaScript will load the web component's custom element and replace all PHP created instances of the template with browser/JavaScript created instances.
## License
This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.