core
core copied to clipboard
View class steroids ππ½
Componetization syntax
Current:
<div>
<?php View::render('myComponent', [
'attr' => 'value'
] ?>
</div>
Requestedππ½π₯
<div>
<f-MyComponent attr="value" />
</div>
-
f
prefix can be customizable - components folder must be defined first or
/views/components
is taken by default and map functions or classes
function MyComponent(array $props): string {
return <<<html
<div>{$props['attr']}</div>
html;
}
// or
class MyComponentClass {
function __construct(array $props) {
// initialize properties, call preparation methods or whatever
}
function render(): string {
// return html code
}
}