PHPackages                             sgflores/optioner - 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. sgflores/optioner

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

sgflores/optioner
=================

A comprehensive Optioner package

v1.0.0(4mo ago)07MITPHPPHP ^8.1

Since Dec 15Pushed 4mo agoCompare

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

READMEChangelog (1)Dependencies (8)Versions (3)Used By (0)

Optioner
========

[](#optioner)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/acffb6ae1962992d26e4466782832787e79504a6250f80d732c4283458b9f497/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75652e737667)](https://www.php.net/)[![Laravel Version](https://camo.githubusercontent.com/3cefaa9e1a00e393b49e2ecba1383d856ade657666fc9cd9188496de84558ad0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531302e3025374325354531312e3025374325354531322e302d7265642e737667)](https://laravel.com/)

A Laravel package that provides dynamic option registration for dropdowns, select boxes, and any UI component that needs predefined or dynamic data.

What is Optioner?
-----------------

[](#what-is-optioner)

Optioner solves the common problem of managing option lists in Laravel applications. Instead of writing repetitive code to fetch and format data for dropdowns, Optioner handles it all through **dynamic registration** within Laravel Service Providers.

### Key Features

[](#key-features)

- ✅ **Dynamic Registration** - Register options programmatically in Service Providers
- ✅ **Static &amp; Callable Data** - Support for both arrays and closures
- ✅ **Automatic Caching** - Built-in caching with configurable TTL
- ✅ **Model Cache Invalidation** - Automatic cache clearing on model changes
- ✅ **RESTful API** - Clean API endpoints for frontend consumption
- ✅ **Artisan Commands** - Developer tools for cache management

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

[](#installation)

Install the package via Composer:

```
composer require sgflores/optioner
```

Quick Setup
-----------

[](#quick-setup)

### 1. Publish Configuration

[](#1-publish-configuration)

```
php artisan vendor:publish --tag=optioner-config
```

### 2. Publish Example Provider and Registrars

[](#2-publish-example-provider-and-registrars)

```
php artisan vendor:publish --tag=optioner-provider
```

This creates the following under `app/Providers/Optioner/`:

- `OptionServiceProvider.php` - boots option registration
- `StaticOptionsRegistrar.php` - example static options
- `DynamicOptionsRegistrar.php` - example dynamic options

### 3. Register Options

[](#3-register-options)

Edit `app/Providers/Optioner/OptionServiceProvider.php` to wire up registrars (already done by default):

```
