1. Go to this page and download the library: Download rahpt/ci4-module-theme 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/ */
use Rahpt\Ci4ModuleTheme\Support\ViewComponent;
// Criando e renderizando um componente isolado
$component = ViewComponent::make('App\Modules\Contratos\Views\components\status_card', [
'title' => 'Contratos Ativos',
'total' => 42
]);
// Renderização em templates
echo $component->render(['highlight' => true]);
// Ou simplesmente interpolando como string
echo $component;
use Rahpt\Ci4ModuleTheme\Support\AssetRegistry;
// Caminho confiável para configuração e manifestos de módulos
AssetRegistry::allowHostFromConfig('cdn.jsdelivr.net');
AssetRegistry::allowHostFromConfig('cdnjs.cloudflare.com');
// Registrar biblioteca vendor homologada com versão
AssetRegistry::registerVendor('chartjs', 'https://cdn.jsdelivr.net/npm/chart.js', [
'type' => 'js',
'version' => '4.4.0'
]);
use Rahpt\Ci4ModuleTheme\ThemeManager;
// Gerar e configurar o token Nonce único por requisição
$nonce = bin2hex(random_bytes(16));
ThemeManager::setNonce($nonce);
// Ao renderizar scripts e estilos no layout:
echo theme_styles(); // <link rel="stylesheet" href="..." nonce="...">
echo theme_scripts(); // <script src="..." nonce="..."></script>
// app/Modules/Contratos/Config/Module.php
class Module extends BaseModule
{
public string $name = 'Contratos';
public string $theme = 'adminlte'; // 'adminlte', 'bootstrap' ou 'custom'
}
use Rahpt\Ci4ModuleTheme\ThemeManager;
public function index()
{
return view('App\Modules\Contratos\Views\index', [
'layout' => ThemeManager::getModuleLayout('Contratos')
]);
}
<?= $this->extend($layout)
// No Controller
set_breadcrumb('Início', '/');
set_breadcrumb('Contratos', 'contratos');
set_breadcrumb('Detalhes');
// Registrar hook de interface
register_hook('before_layout', function($data) {
return '<!-- Hook injetado antes do layout -->';
});
// Na View de Layout
<?= render_breadcrumbs()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.