PHPackages                             moonspot/component - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. moonspot/component

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

moonspot/component
==================

Library for creating HTML components in PHP

1.0.2(6mo ago)01091BSD-3-ClausePHPPHP ^8.1CI passing

Since Jun 16Pushed 6mo agoCompare

[ Source](https://github.com/brianlmoon/component)[ Packagist](https://packagist.org/packages/moonspot/component)[ RSS](/packages/moonspot-component/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (5)Used By (1)

Moonspot\\Component
===================

[](#moonspotcomponent)

A library for creating HTML components in PHP.

Creating consitent HTML components is important for good user experience. This library aims to make creating those components easier. It is the result of work I have done for years on different projects. A prime reason for this library and some of the techniques it uses is performance.

Example
-------

[](#example)

### Text Input

[](#text-input)

```
use Moonspot\Component\ComponentAbstract;

class TextInput extends ComponentAbstract {

    // Define the attributes for the component as public properties
    // id and class are defined in the parent class for all components.
    public string   $type      = 'text';
    public string   $name      = '';
    public bool     $required  = false;
    public int|null $minlength = null;
    public int|null $maxlength = null;
    public int|null $size      = null;

    // For other settings, define them as protected properties
    protected string $label = '';

    // function where the markup is defined
    public function markup() {
        ?>
