PHPackages                             vildanhakanaj/php-options - 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. vildanhakanaj/php-options

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

vildanhakanaj/php-options
=========================

Simple way to interact with an options array in your website

v0.2.0(2y ago)019MITPHPPHP ^8.2

Since Dec 25Pushed 11mo ago1 watchersCompare

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

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

Options
=======

[](#options)

A simple way to manage an options array for site, articles, pages etc.

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

[](#requirements)

- php 7.4 and above

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

[](#installation)

### Using composer

[](#using-composer)

```
composer require vildanhakanaj/php-options
```

Usage
-----

[](#usage)

### Instantiate

[](#instantiate)

```
use VildanHakanaj\Options;

$options = new Options([
    "key1" => "value1",
    "key2" => "value2"
]);
// or
$options = Options::fromArray([
    "key1" => "value1",
    "key2" => "value2"
]);
```

### Set options

[](#set-options)

```
// Set options
// Use magic setters
$options->key = "value";
// Merge with key value
$options->mergeKey("key", "value");
// Merge an array with key values
$options->merge(["key" => "value", "key1" => "value1"]);
// override options with the given array
$options->override(["newKey" => "newValue"]);
// Only add if its not already in the options
$options->addIfUnique("key", "value");
```

### Access options

[](#access-options)

```
// Any of the merge operations will override if any of the keys already exists in the options array.
// get value out of options
//Will return null if the key is not found
$value = $options->get("key");
$value = $options->key;
$value = $options["key"];
//Get all values
$values = $options->values();
//Get all keys
$keys = $options->keys();
//Get all options
$array = $options->all();
//Check if the key is in options array
$boolean = $options->has("key");
```

### Filter options

[](#filter-options)

```
//Filter by value
$filteredOptions = $options->filter(function($option){
    return true; /*logic for filtering*/
});
// Remove the falsy values
$onlyTruthyValues = $options->filter();
//Filter by key
$filteredOptions = $options->filterByKey(function($option){
    return true; /*logic for filtering*/
});
```

### Iterable

[](#iterable)

```
foreach(Option::fromArray(["key" => "value"]) as $optionKey => $optionValue){
    // $optionKey = "key";
    // $optionValue = "value";
}
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Recently: every ~121 days

Total

6

Last Release

747d ago

PHP version history (4 changes)v0.1.0PHP ^7.4

v0.1.1PHP ^7.4 || ^8.0

v0.1.4PHP ^7.4 || ^8.2

v0.2.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![VildanHakanaj](https://avatars.githubusercontent.com/u/23201587?v=4)](https://github.com/VildanHakanaj "VildanHakanaj (35 commits)")

---

Tags

arrayarray-optionsoptionsphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vildanhakanaj-php-options/health.svg)

```
[![Health](https://phpackages.com/badges/vildanhakanaj-php-options/health.svg)](https://phpackages.com/packages/vildanhakanaj-php-options)
```

###  Alternatives

[thalidzhokov/country-codes

CountryCodes PHP Class to get array of countries with ISO 3166-1 alpha-2, ISO 3166-1 alpha-3, ISO 3166-1 numeric and ISD codes it can provide following information related to country

13111.5k](/packages/thalidzhokov-country-codes)

PHPackages © 2026

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