PHPackages                             pifeifei/hyperf-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. pifeifei/hyperf-options

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

pifeifei/hyperf-options
=======================

v0.1.1(5y ago)05MITPHPPHP &gt;=7.2

Since Aug 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/pifeifei/hyperf-options)[ Packagist](https://packagist.org/packages/pifeifei/hyperf-options)[ RSS](/packages/pifeifei-hyperf-options/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (8)Versions (3)Used By (0)

hyperf options
==============

[](#hyperf-options)

```
composer require pifeifei/hyperf-options

```

使用
--

[](#使用)

```
// app/Constants/AbstractConstants.php
namespace App\Constants;
class AbstractConstants extends \Hyperf\Constants\AbstractConstants
{
    use \Pff\HyperfOptions\Concerns\OptionsConstants;
}
// app/Constants/Status.php
class Status extends AbstractConstants
{
    /**
     * @Message("ok")
     * @Info("content 1")
     * @Desc("sequential_array")
     * @GoodsInfoDesc("abcde")
     */
    const SERVER_OK = 1;

    /**
     * @Message("delete")
     * @Info("content -1")
     * @lang("validation.sequential_array")
     */
    const SERVER_DELETE = -1;

    /**
     * @Message("forbid")
     * @Info("content 0")
     */
    const SERVER_FORBID = 0;
}

// app/Model/Model.php
namespace App\Model;
abstract class Model extends \Hyperf\DbConnection\Model\Model
{
    use \Pff\HyperfOptions\Concerns\Options;
}

namespace App\Model;
class Test extends Model
{
    /* @var array */
    public $options = [
    //    'status' => [Status::class, 'Message'],
    //    'status' => Status::class, // default: Message
        'status' => [\App\Constants\Status::class, 'info']
    ];

    /**
     * @return mixed
     */
    public function getStatusOptionAttribute()
    {
        return $this->getOption('status');
    }

    public function getStatusOptionsAttribute($default = null)
    {
        return $this->getStatusOptions($default);
    }
}

// use
$test = new \App\Model\Test();
$result = $test::query()->orderByDesc('id')->first(); // {"id":1,"status":1}
var_dump($result->status_option); // return：'content 1'
var_dump($result->status_options); // return: [1=>'content 1', 0=>'content 0', -1 => 'content -1']
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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

2084d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

hyperfoptionsphphyperf

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pifeifei-hyperf-options/health.svg)

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

PHPackages © 2026

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