1. Go to this page and download the library: Download yuga/livecomponent library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\\Live;
use Yuga\Live\Attributes\Live;
use Yuga\Live\Component;
#[Live(name: 'counter')]
class Counter extends Component
{
public int $count = 0;
public function increment(): void
{
$this->count++;
}
public function render(): string
{
return <<<HTML
<section>
<strong>{$this->count}</strong>
<button type="button" ylc:click="increment">+</button>
</section>
HTML;
}
}
public function mount(int $customerId): void
{
$this->customerId = $customerId;
}
use Yuga\Live\Form;
class ProfileForm extends Form
{
public string $name = '';
public string $email = '';
public function rules(): array
{
return [
'name' => '
public ProfileForm $form;
public function save(): void
{
if (!$this->form->validate()) {
return;
}
// Persist $this->form->all().
$this->form->reset();
}
use Yuga\Live\Attributes\Url;
#[Url(as: 'q')]
public string $search = '';
#[Url(history: false)]
public int $page = 1;
use Yuga\Live\Attributes\Computed;
#[Computed]
public function getTotalProperty(): int
{
return $this->items->sum('price');
}
public function boot(): void {}
public function mount(...$params): void {}
public function hydrate(): void {}
public function dehydrate(): void {}
public function updating(string $property, mixed $value): void {}
public function updated(string $property, mixed $value): void {}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.