1. Go to this page and download the library: Download ui-awesome/html-core 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/ */
declare(strict_types=1);
namespace App;
use BackedEnum;
use UIAwesome\Html\Core\Element\BaseInput;
use UIAwesome\Html\Interop\{Inline, Voids};
final class SearchInput extends BaseInput
{
protected function getTag(): BackedEnum
{
return Voids::INPUT;
}
protected function run(): string
{
return $this->buildElement();
}
}
echo SearchInput::tag()
->type('search')
->name('q')
->prefix('Search')
->prefixTag(Inline::LABEL)
->render();
// <label>Search</label>
// <input name="q" type="search">
declare(strict_types=1);
namespace App;
use UIAwesome\Html\Core\Element\BaseBlock;
use UIAwesome\Html\Interop\Block;
use BackedEnum;
final class Div extends BaseBlock
{
protected function getTag(): BackedEnum
{
return Block::DIV;
}
}
echo Div::tag()
->class('card')
->content('Content')
->render();
// <div class="card">
// Content
// </div>
declare(strict_types=1);
namespace App;
use UIAwesome\Html\Core\Element\BaseBlock;
use UIAwesome\Html\Interop\Block;
use BackedEnum;
final class Div extends BaseBlock
{
protected function getTag(): BackedEnum
{
return Block::DIV;
}
}
echo Div::tag()->begin();
echo 'Nested Content';
echo Div::end();
// <div>
// Nested Content
// </div>
declare(strict_types=1);
namespace App;
use UIAwesome\Html\Core\Element\BaseInline;
use UIAwesome\Html\Interop\Inline;
use BackedEnum;
final class Span extends BaseInline
{
protected function getTag(): BackedEnum
{
return Inline::SPAN;
}
protected function run(): string
{
return $this->buildElement($this->getContent());
}
}
echo Span::tag()
->content('Content')
->prefix('Prefix')
->prefixTag(Inline::STRONG)
->suffix('Suffix')
->suffixTag(Inline::EM)
->render();
// <strong>Prefix</strong>
// <span>Content</span>
// <em>Suffix</em>
declare(strict_types=1);
namespace App;
use UIAwesome\Html\Core\Base\BaseTag;
use UIAwesome\Html\Core\Element\BaseInline;
use UIAwesome\Html\Core\Factory\SimpleFactory;
use UIAwesome\Html\Core\Provider\{DefaultsProviderInterface, ThemeProviderInterface};
use UIAwesome\Html\Interop\Inline;
use BackedEnum;
final class Span extends BaseInline
{
protected function getTag(): BackedEnum
{
return Inline::SPAN;
}
protected function run(): string
{
return $this->buildElement($this->getContent());
}
}
final class Defaults implements DefaultsProviderInterface
{
public function getDefaults(BaseTag $tag): array
{
return ['class' => 'badge'];
}
}
final class Theme implements ThemeProviderInterface
{
public function apply(BaseTag $tag, string $theme): array
{
return $theme === 'muted' ? ['class' => 'text-muted'] : [];
}
}
SimpleFactory::setDefaults(Span::class, ['title' => 'from-global']);
echo Span::tag(['id' => 'badge-1'])
->addDefaultProvider(Defaults::class)
->addThemeProvider('muted', Theme::class)
->content('New')
->render();
// <span class="badge text-muted" id="badge-1" title="from-global">New</span>
declare(strict_types=1);
namespace App;
use UIAwesome\Html\Core\Element\BaseBlock;
use UIAwesome\Html\Interop\Block;
use BackedEnum;
final class Container extends BaseBlock
{
protected function getTag(): BackedEnum
{
return Block::DIV;
}
protected function loadDefault(): array
{
return [
'class' => 'container',
];
}
}
echo Container::tag()->render();
// <div class="container">
// </div>
echo Container::tag(['class' => 'container-fluid'])->render();
// <div class="container container-fluid">
// </div>
enum SvgTag: string
{
case SVG = 'svg';
case G = 'g';
// ... add other SVG block tags as needed
}
// now you can use it with the Html renderer or your custom classes
echo Html::element(SvgTag::G, '...');
// <g>...</g>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.