You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,21 +38,22 @@ Since Leaf UI is modelled after React, everything is a component. You can create
38
38
```php
39
39
<?php
40
40
41
-
use Leaf\UI\Core;
42
41
use Leaf\UI\Component;
43
42
44
43
class Test2 extends Component
45
44
{
45
+
// every component needs a unique key
46
+
public $key = "test2";
46
47
public $count = 1;
47
48
48
49
public function increment()
49
50
{
50
-
$this->count = $this->count + 1;
51
+
$this->count++;
51
52
}
52
53
53
54
public function decrement()
54
55
{
55
-
$this->count = $this->count - 1;
56
+
$this->count--;
56
57
}
57
58
58
59
public function render()
@@ -63,7 +64,7 @@ class Test2 extends Component
63
64
<div>
64
65
<div>Static text</div>
65
66
<button@click="decrement">-</button>
66
-
<h1>' . $this->count . '</h1>
67
+
<h1>{{ $count }}</h1>
67
68
<button@click="increment">+</button>
68
69
</div>
69
70
</body>
@@ -79,17 +80,19 @@ To actually make this work, you simply need to render this component wherever yo
79
80
```php
80
81
<?php
81
82
82
-
use Leaf\UI\Core;
83
+
use Leaf\UI;
83
84
84
-
require_once __DIR__ . '/vendor/autoload.php';
85
+
require __DIR__ . '/vendor/autoload.php';
85
86
86
-
echo Core::render(new Test2());
87
+
UI::render(new Test2());
87
88
```
88
89
89
90
The most beautiful part about all this is that it can run outside Leaf. It is completely independent of Leaf or any other framework and can be used in any PHP application.
90
91
91
92
_This file is still being updated!_
92
93
94
+
***Docs @ https://staging.ui.leafphp.dev are still being updated.***
0 commit comments