PHPackages                             tenthfeet/select-options-helper - 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. tenthfeet/select-options-helper

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

tenthfeet/select-options-helper
===============================

Flexible select options generator for PHP/Laravel

v1.1.0(1mo ago)334MITPHPPHP ^8.1

Since Sep 22Pushed 1mo agoCompare

[ Source](https://github.com/tenthfeet/select-options-helper)[ Packagist](https://packagist.org/packages/tenthfeet/select-options-helper)[ RSS](/packages/tenthfeet-select-options-helper/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

Select Options Helper
=====================

[](#select-options-helper)

Flexible and reusable PHP helper to generate HTML elements from arrays, collections, or models. Works in Laravel and plain PHP.

Features
--------

[](#features)

- Accepts **arrays, collections, objects, and models**.
- Supports **callables** for customizing option text and value.
- Lazy normalization for **memory-efficient** iteration.
- Optional **Laravel integration**: Blade directives, collection macros, and config defaults.
- Framework-agnostic — works outside Laravel too.

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

[](#installation)

Via Composer:

```
    composer require tenthfeet/select-options-helper
```

Usage/Examples
--------------

[](#usageexamples)

**Signature:**

```
    generate_options(
        iterable $data,
        array $selected = [],
        string $placeholder = '',
        bool $readonly = false,
        string|callable $textKey = 'text',
        string|callable|null $valueKey = null
    ): string
```

**Parameters:**

- `$data` – Array, collection, or objects/models.
- `$selected` – Array of values to mark selected.
- `$placeholder` – Optional placeholder text for ``.
- `$readonly` – Whether to disable the placeholder option.
- `$textKey` – Property name or callable to generate option text.
- `$valueKey` – Property name or callable to override option value.

**Plain PHP:**

```
// Simple key/value array
echo generate_options(['1' => 'One', '2' => 'Two'], ['2'], 'Select an option');

// Array of id/text
$data = [
    ['id' => 1, 'text' => 'Option 1'],
    ['id' => 2, 'text' => 'Option 2']
];
echo generate_options($data, [1]);

// Object/Model array
$users = [
    (object) ['id' => 1, 'first_name' => 'John', 'last_name' => 'Doe'],
    (object) ['id' => 2, 'first_name' => 'Jane', 'last_name' => 'Smith']
];
echo generate_options($users, [], 'Choose user', false, fn($u) => "{$u->first_name} {$u->last_name}");
```

**Laravel**

```

    @options($users, [1,2], 'Choose user')

```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance92

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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 ~123 days

Total

3

Last Release

38d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af032b274982990a0429c5d5f74ba2dd3a18b0f6e7c95b6c4666237a5599e7e4?d=identicon)[Tenthfeet](/maintainers/Tenthfeet)

---

Top Contributors

[![perumalcodes](https://avatars.githubusercontent.com/u/97530388?v=4)](https://github.com/perumalcodes "perumalcodes (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tenthfeet-select-options-helper/health.svg)

```
[![Health](https://phpackages.com/badges/tenthfeet-select-options-helper/health.svg)](https://phpackages.com/packages/tenthfeet-select-options-helper)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M10](/packages/renatomarinho-laravel-page-speed)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M282](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.6M375](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

244.6M136](/packages/illuminate-cookie)

PHPackages © 2026

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