https://github.com/repcomm/component-php
exponent-ts pseudo-ported to PHP so I don't have to write screwy PHP code
https://github.com/repcomm/component-php
Last synced: 10 months ago
JSON representation
exponent-ts pseudo-ported to PHP so I don't have to write screwy PHP code
- Host: GitHub
- URL: https://github.com/repcomm/component-php
- Owner: RepComm
- Created: 2020-11-30T04:00:23.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-30T18:59:48.000Z (about 5 years ago)
- Last Synced: 2025-01-28T08:51:41.308Z (about 1 year ago)
- Language: PHP
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
Awesome Lists containing this project
README
# component
A pseudo-port of [exponent-ts](https://github.com/RepComm/exponent-ts) for PHP
Example usage
```php
//include the lib
include_once("component.php");
function test_component_php () {
//Create a container for our content
$content = new Component();
$content->make("div")->
textContent("Hello World")->
//Styling
styleItem("position", "absolute")->
styleItem("top", "25%")->
styleItem("left", "25%")->
styleItem("width", "50vw")->
styleItem("height", "50vh")->
styleItem("background-color", "black")->
styleItem("color", "white");
//Iterate from 0 to 9
//Declaring variable outside of the loop should save us some performance
$child = 0;
for ($i=0; $i < 10; $i++) {
//Create a line break
$child = new Component();
$child->make("br")->
//attach to the content as a child
mount($content);
//Create text span
$child = new Component();
$child->make("span")->
//set the text content to "span " + iteration number
textContent("span " . sprintf("%d", $i) )->
//attach to the content as a child
mount($content);
}
//walk the hierarchy and echo the HTML generated
writeComponent($content);
}
test_component_php();
```