PHP code example of dgvirtual / codeigniter4-components
1. Go to this page and download the library: Download dgvirtual/codeigniter4-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/ */
dgvirtual / codeigniter4-components example snippets
<x-button-green onclick="alert('I was clicked!')">
<?= $clickMeLabel
public $componentsLookupPaths = [
// your local components
APPPATH . 'Views/Components/',
// example components
__DIR__ . '/../Components/',
];
namespace Config;
use Dgvirtual\Components\Config\Components as BaseComponents;
class Components extends BaseComponents
{
public $componentsLookupPaths = [
APPPATH . 'Views/Components/',
];
/**
* Cache all view-only components for 10 minutes.
* Set to null (default) to disable.
*/
public ?int $viewCacheTtl = 600;
}
class AvatarComponent extends Component
{
/**
* Cache the rendered HTML for 1 hour.
* Null (default) means no renderer caching.
*/
public ?int $cacheTtl = 3600;
}
class UserCardComponent extends Component
{
public ?int $cacheTtl = 300;
public function cacheKey(): string
{
// One cache entry per user
return (string) session('user_id');
}
}
html
<x-famous-quotes seconds="30" />
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.