PHPackages                             himanshu-m/accessors - 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. himanshu-m/accessors

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

himanshu-m/accessors
====================

Define getter and setter for inaccessible members of a PHP class

0.0.2(3y ago)0352MITPHPPHP &gt;=7.4

Since Apr 15Pushed 3y ago1 watchersCompare

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

READMEChangelog (2)DependenciesVersions (3)Used By (2)

PHP Accessors
=============

[](#php-accessors)

Define getter and setter for inaccessible members of a PHP class

Installation
============

[](#installation)

`composer require himanshu-m/accessors`

Usage
=====

[](#usage)

Use the trait in any class to build getter and/or setters for the private and protected properties of the classes. It can also allow instance method which do not accept any arguments to invoked just like using a property of the object.

```
use Accessors;

class AccessorsTest
{
    use Accessors;

    private string $prop1;
    private string $prop2;

    function __construct(string $p1, string $p2)
    {
	$this->prop1 = $p1;
	$this->prop2 = $p2;

	$this->acccessible("prop1");
	// prop2 can also be renamed as readonlyProp for access from outside.
	$this->readonly("readonlyProp", "prop2");
    }
}

$obj = new AccessorsTest("property1", "property2");

echo $obj->prop1;
// property1
$obj->prop1 = "changed prop1";
echo $obj->readonlyProp;
// property2
$obj->readonlyProp = "cannot change prop2...";
// Exception: Property 'readonlyProp' of class AccessorsTest is not accessible
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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

1121d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/290327a9259a7d38d2269bab5163e81e48bd78f989e8ce34c37b6c13f266c6c1?d=identicon)[HimanshuM](/maintainers/HimanshuM)

---

Top Contributors

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

---

Tags

gettersetterreadonly

### Embed Badge

![Health badge](/badges/himanshu-m-accessors/health.svg)

```
[![Health](https://phpackages.com/badges/himanshu-m-accessors/health.svg)](https://phpackages.com/packages/himanshu-m-accessors)
```

###  Alternatives

[usmanhalalit/get-set-go

Dynamic Setter-Getter for PHP 5.4+

1813.4k1](/packages/usmanhalalit-get-set-go)[antares/accessible

PHP library that allows you to define your class' getters, setters and constructor with docblock annotations.

123.9k1](/packages/antares-accessible)

PHPackages © 2026

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