paulkre / react
This package is abandoned and no longer maintained.
No replacement package was suggested.
React-like library for component based development in PHP
0.1.0
2021-09-04 13:10 UTC
This package is not auto-updated.
Last update: 2023-03-19 19:15:35 UTC
README
React-like library for component based development in PHP.
Usage
class MyComponent extends \React\Component { static function render($props = []) { ?> <p>This is the message: <?= $props['msg'] ?></p> <?php } } class MyOtherComponent extends \React\Component { static function render($props = []) { ?> <div> <?php self::render_children($props['children']) ?> </div> <?php } } // Basic MyComponent::render(['msg' => 'Hello World!']); // Nested MyOtherComponent::render([ 'children' => [ new MyComponent(['msg' => 'First child']), new MyComponent(['msg' => 'Second child']), ] ]);
I recommend using webpack so you can co-locate both the back end and the front end code of each component in the same directory. The structure for a generic project could look like this:
.
└── src
├── MyComponent
│ ├── Component.php
│ ├── index.js
│ └── style.css
├── MyOtherComponent
│ ├── Component.php
│ ├── index.js
│ └── style.css
└── index.js