PHP code example of assertchris / laravel-renderless-components
1. Go to this page and download the library: Download assertchris/laravel-renderless-components 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/ */
assertchris / laravel-renderless-components example snippets
namespace App\View\Components;
use RenderlessComponents\RenderlessComponent;
class List extends RenderlessComponent
{
public array $items = [];
public function __construct(array $items)
{
$this->items = $items;
}
public function view(): string
{
return 'components.tailwind-list';
}
public function viewParams(): array
{
// think of this as the array of params
// you usually give as the second argument
// of the view() function
return [
'items' => $this->items,
];
}
public function renderParams(): string
{
// think of this as the list of arguments
// you give to the render function
return '$params, $count';
}
}