Installation and usage guide.
Install the package by running
composer require robinn/uikit
Initialize UI Kit and then call methods or simply use get_ui()
helper function.
Components can be loaded in several ways. It's up to you what you choose.
use RobiNN\UiKit\UiKit;
$uikit = new UiKit();
ob_start();
// ...
$uikit->layout(ob_get_clean());
$uikit->
can be replaced byget_ui()->
function, or simply use for everything helper functions.Note: when using
get_ui()
and you want custom config, you have to redeclare this function.
Simply print everything with echo.
ob_start();
echo 'HTML code';
echo alert('Default');
echo layout(ob_get_clean(), [
'title' => 'Site title',
]);
It is also possible to call components in a template.
$html = get_ui()
->addPath(__DIR__.'/templates') // Path to dir with custom templates
->render('page'); // page.twig in templates/ dir
echo layout($html, [
'title' => 'Site title',
]);
page.twig
HTML code
{{ alert('Default') }}
If you use components with helper functions, the simplest way to change config is to override get_ui()
function.
Simply place this function after class autoload.
function get_ui(): RobiNN\UiKit\UiKit {
return RobiNN\UiKit\UiKit::getInstance([
'cache' => __DIR__.'/cache',
]);
}
All options can be found here.
layout()
is not required and components can be used in any project that uses a compatible CSS framework.