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.0.1(7mo ago)212MITPHPPHP ^8.1

Since Sep 22Pushed 7mo 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 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)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

34

—

LowBetter than 77% of packages

Maintenance66

Regular maintenance activity

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Total

2

Last Release

229d 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 (2 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

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M210](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M858](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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