PHPackages                             hstanleycrow/easyphpwebcomponents - 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. hstanleycrow/easyphpwebcomponents

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

hstanleycrow/easyphpwebcomponents
=================================

Free PHP web components library like lists, buttons, dropdowns, and more.

1.1.0(1mo ago)023↓66.7%3MITPHPPHP ^8.0

Since Nov 18Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/hstanleycrow/EasyPHPWebComponents)[ Packagist](https://packagist.org/packages/hstanleycrow/easyphpwebcomponents)[ Docs](https://github.com/hstanleycrow/EasyPHPWebComponents)[ RSS](/packages/hstanleycrow-easyphpwebcomponents/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (5)Used By (3)

English | [Español](README.es.md)

EasyPHPWebComponents
====================

[](#easyphpwebcomponents)

PHP library for building web components such as lists, buttons, dropdowns, and more.

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Composer
- A web server (Apache) or PHP's built-in server

The library generates plain HTML and does not depend on any CSS framework. Bootstrap is just an example used in `examples.php`; any framework (or none) works via `addClass()`.

Installation
------------

[](#installation)

```
# Clone this repository
$ git clone https://github.com/hstanleycrow/EasyPHPWebComponents.git
cd EasyPHPWebComponents
composer install
```

Or using Composer

```
$ composer require hstanleycrow/easyphpwebcomponents
```

Usage
-----

[](#usage)

Components render plain HTML; you add CSS classes yourself with `addClass()`. The `examples.php` example uses Bootstrap 5.3.8 and Font Awesome 6.4.2, but they are optional, not a requirement of the library.

```

```

Quick example
-------------

[](#quick-example)

```
use hstanleycrow\EasyPHPWebComponents\Icon;
use hstanleycrow\EasyPHPWebComponents\Button;

require 'vendor/autoload.php';

$buttonText = (new Icon('fa fa-home', 'Submit'))->render();

echo (new Button($buttonText))
    ->addClass('btn btn-primary')
    ->setId('my-button')
    ->render();
```

```
A full example is available in `examples.php`.
```

Available components
--------------------

[](#available-components)

- `Icon` – Renders an icon with text using CSS classes (e.g. Font Awesome).
- `Button` – A button with HTML content, classes, and attributes.
- `Link` – An anchor with HTML content and attributes (e.g. `target`, `class`).
- `Select` – A `` dropdown with options and a selected value.
- `UnorderedList` – A `` list with a bullet type.
- `OrderedList` – An `` list with a numbering type.

All of them implement `Renderable` (`render(): string`). To build your own component without modifying the library, just implement that interface:

```
use hstanleycrow\EasyPHPWebComponents\Renderable;

class Badge implements Renderable
{
    public function __construct(private string $text) {}

    public function render(): string
    {
        return '' . $this->text . '';
    }
}
```

Public methods
--------------

[](#public-methods)

### Icon

[](#icon)

MethodDescription`__construct(string $iconClass, string $buttonText, string $iconPosition = 'left')`Creates the icon. Throws `InvalidArgumentException` if `$iconClass`/`$buttonText` are empty or `$iconPosition` is not `left`/`right`.`render(): string`Returns the icon's HTML.### Button

[](#button)

MethodDescription`__construct(string $buttonText, ?string $type = 'button')`Throws `InvalidArgumentException` if `$buttonText` is empty.`addClass(string $class): self`Adds CSS classes.`setId(string $id): self`Sets the `id`.`setDisabled(bool $disabled): self`Toggles the `disabled` attribute.`render(): string`Returns the button's HTML.### Link

[](#link)

MethodDescription`__construct(string $href, string $linkContent)`Throws `InvalidArgumentException` if `$href`/`$linkContent` are empty.`addClass(string $class): self`Adds CSS classes.`setRel(string $rel): self`Sets `rel`.`setTarget(string $target): self`Sets `target` (default `_self`).`setDownload(string $download): self`Sets `download`.`render(): string`Returns the link's HTML.### Select

[](#select)

MethodDescription`__construct(array $options = [], ?string $selected = null)``$options` is `[value => label]`.`addClass(string $class): self`Adds CSS classes.`setId(string $id): self` / `getId(): string`Select's id.`setName(string $name): self` / `getName(): string`The `name` attribute.`setDisabled(bool $disabled): self`Toggles `disabled`.`setMultiple(bool $multiple): self`Toggles multiple selection.`render(): string`Returns the `` HTML with its ``s.### OrderedList

[](#orderedlist)

MethodDescription`__construct(?string $type = '1')`Numbering type (`1`, `a`, `A`, `i`, `I`).`addItem(string $item): self`Adds a ``.`setType(string $type): self`Changes the numbering type.`render(): string`Returns the list's HTML.### UnorderedList

[](#unorderedlist)

MethodDescription`__construct(?string $type = 'circle')``list-style-type` value (`circle`, `disc`, `square`, `none`...).`addItem(string $item): self`Adds a ``.`setType(string $type): self`Changes the `list-style-type`.`addClass(string $class): self`Adds CSS classes.`setId(string $id): self`Sets the `id`.`render(): string`Returns the list's HTML.Tests
-----

[](#tests)

```
composer test
```

See [tests/](tests/) for the cases covered (happy path and errors) per component.

AI assistant documentation
--------------------------

[](#ai-assistant-documentation)

See [AI\_USAGE.md](AI_USAGE.md).

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~482 days

Total

3

Last Release

47d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/713da77764977a76a357f6b34361a7ab51bd55ea847b84112e3a38f5496af173?d=identicon)[hstanleycrow](/maintainers/hstanleycrow)

---

Top Contributors

[![hstanleycrow](https://avatars.githubusercontent.com/u/7930763?v=4)](https://github.com/hstanleycrow "hstanleycrow (18 commits)")

---

Tags

phpcomponentsweb components

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hstanleycrow-easyphpwebcomponents/health.svg)

```
[![Health](https://phpackages.com/badges/hstanleycrow-easyphpwebcomponents/health.svg)](https://phpackages.com/packages/hstanleycrow-easyphpwebcomponents)
```

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21524.3k](/packages/imanghafoori-laravel-anypass)[okipa/laravel-form-components

Ready-to-use and customizable form components.

208.2k1](/packages/okipa-laravel-form-components)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
