PHP code example of iurigustavo / craft-livewire-bridge

1. Go to this page and download the library: Download iurigustavo/craft-livewire-bridge 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/ */

    

iurigustavo / craft-livewire-bridge example snippets




use CraftCms\Cms\Entry\Elements\Entry;
use Livewire\Attributes\Layout;
use Livewire\Component;

new #[Layout('layouts::app')] class extends Component {
    public Entry $entry;

    public int $likes = 0;

    public function rendering($view): void
    {
        $view->title($this->entry->title);
    }

    public function like(): void
    {
        $this->likes++;
    }
};

public Entry $entry;                       // filled automatically

public function mount(Entry $entry): void  // or received here
{
    // ...
}