PHPackages                             saberyjs/refl-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. saberyjs/refl-helper

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

saberyjs/refl-helper
====================

this library can help create object of specified class,or call specified method of specified clas

2.0(8y ago)1251MITPHPPHP &gt;5.6

Since Mar 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/SABERYJS/php-refl-helper)[ Packagist](https://packagist.org/packages/saberyjs/refl-helper)[ RSS](/packages/saberyjs-refl-helper/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (2)Used By (1)

php-refl-helper
===============

[](#php-refl-helper)

actually this library is a light PHP dependency injector

why to use this library.
------------------------

[](#why-to-use-this-library)

if you are a PHP developer, you will know that,PHP has a feature called *Reflection*,with that,you can do cool things,as follows: you can create a Object dynamic,even there is some dependences,this library will create it for you,not only but also,you can call any public method of it ,its dependences will also be parsed.

how to use
----------

[](#how-to-use)

first,we assume that there are two class,code is here:

```
class Apple{
  public function  shape(){
    return 'red';
  }
}

class Person{
  public function eat(Apple $apple){
    echo $apple->shape();
  }
}

class  Hunter{
    protected $weapon;
    public function __construct(Weapon $weapon)
    {
        $this->weapon=$weapon;
    }

    public function showWeapon(){
        $this->weapon->display();
    }

    private static function  getInstance(Weapon $weapon){
        return new self($weapon);
    }

    public static function create(Weapon $weapon){
        return new self($weapon);
    }
}

class  Weapon{
    private $name;
    private $price;
    private $type;
    private $level;
    public function __construct($name,$price,$type,$level)
    {
        $this->name=$name;
        $this->price=$price;
        $this->type=$price;
        $this->level=$level;
    }

    public function display(){
        echo 'weapon detail of'.$this->name.':'.$this->price.'-'.$this->type.':'.$this->level;
    }
}
```

as you see,there are two class called *Apple* and *Person*, if you want to call eat method of *Person* ,you can do like this. following code show how you can use this library.

```
$defaultConfig=[
    'name'=>"saberyjs",
    'price'=>100,
    'type'=>'Melee',
    'level'=>4
];
$config=[
    'method'=>[
        'getInstance',
        'create'
    ],
    'factory'=>[
        Hunter::class=>function(){
            return new Hunter($routeHelper->get(Weapon::class));
        }
    ]
];
$reflHelper=new ReflHelper($config,$defaultConfig);
$reflHelper->callMethod($reflHelper->get(Apple::class),'eat');

$reflHelper->get(Hunter::class)->display();
```

as you see ,this library is very easy to use.totally,you can follows:

- call $reflHelper-&gt;get() can get a object
- call $reflHelper-&gt;callMethod() can call a method of a object
- call $reflHelper-&gt;callStaticMethod() can call static method

if you look upper code carefully,you will find we pass two args($config,$defaultConfig) when we create *ReflHelper*,$config contain two main key(method,factory), the method key specify the method that will be called when library create instance,if class`\_\_constructor not exist,$defaultConfig contain default value that will be used if it is a dependency of other

ReflHelper will do everything for you,even,you do not need to create Apple object,not only but also,this library also also support a function : upper code will create instance of specified class,parse dependency

contact
-------

[](#contact)

*email*:*QQ*:1174332406

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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

Unknown

Total

1

Last Release

2983d ago

### Community

Maintainers

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

---

Top Contributors

[![SABERYJS](https://avatars.githubusercontent.com/u/12248909?v=4)](https://github.com/SABERYJS "SABERYJS (7 commits)")[![freedevcode](https://avatars.githubusercontent.com/u/201516844?v=4)](https://github.com/freedevcode "freedevcode (2 commits)")

### Embed Badge

![Health badge](/badges/saberyjs-refl-helper/health.svg)

```
[![Health](https://phpackages.com/badges/saberyjs-refl-helper/health.svg)](https://phpackages.com/packages/saberyjs-refl-helper)
```

###  Alternatives

[liaison/revision

Seamless software updates library for CodeIgniter4 projects.

186.4k1](/packages/liaison-revision)

PHPackages © 2026

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