PHPackages                             usmanhalalit/get-set-go - 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. usmanhalalit/get-set-go

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

usmanhalalit/get-set-go
=======================

Dynamic Setter-Getter for PHP 5.4+

1.0.0(12y ago)1813.4k41MITPHPPHP &gt;=5.4.0

Since Jun 25Pushed 12y ago2 watchersCompare

[ Source](https://github.com/usmanhalalit/GetSetGo)[ Packagist](https://packagist.org/packages/usmanhalalit/get-set-go)[ Docs](https://github.com/usmanhalalit/GetSetGo)[ RSS](/packages/usmanhalalit-get-set-go/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (1)

GetSetGo [![Build Status](https://camo.githubusercontent.com/a07b20583ea60cc81f256a3ee402df3ac2b912ca8f3b98cb29828e6e667de3ee/68747470733a2f2f7472617669732d63692e6f72672f75736d616e68616c616c69742f476574536574476f2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/usmanhalalit/GetSetGo)
=======================================================================================================================================================================================================================================================================================================

[](#getsetgo-)

A dynamic setter-getter library for PHP 5.4+.

You can use methods like `setFoo('bar')` and `getFoo()`, which you DON'T have to create (in your class). GetSetGo will make these methods work for you automatically as long as you have a `$foo` property in your class.

It makes use of Traits, so `using` it is super simple, you don't have to extend any class, as you can extend a single class only, we don't force you to use ours. You can restrict to only getter only or you can specify a Type for property using **annotations**.

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

[](#installation)

GetSetGo uses [Composer](http://getcomposer.org/) to make hassles Go.

Learn to use composer and add this to require (in your composer.json):

```
"usmanhalalit/get-set-go": "1.*@dev"

```

Library on [Packagist](https://packagist.org/packages/usmanhalalit/get-set-go).

Usage
-----

[](#usage)

Just add this in your classes:

```
use \GetSetGo\SetterGetter;

```

Example:

```
Class MyClass{
    use \GetSetGo\SetterGetter;

    protected $foo;
}
```

Now use it as

```
$myClass = new MyClass;

$myClass->setFoo('bar');
echo $myClass->getFoo();
```

**That's basically it.**

### Restrict Getter or Setter or Both

[](#restrict-getter-or-setter-or-both)

You can use annotation in you class property if you want to disable setter, getter or both using `@setter` and `@getter` annotation variables.

```
/**
 * We can't use setSomeProperty() anymore.
 *
 * @var
 * @setter false
 */
protected $someProperty;
```

---

```
/**
 * We can't use getSomeProperty() anymore.
 *
 * @var \stdClass
 * @getter false
 */
protected $someProperty;
```

---

```
/**
 * We can't use setSomeProperty() or getSomeProperty().
 *
 * @getter false
 * @setter false
 */
protected $someProperty;
```

### Force a Type or Class

[](#force-a-type-or-class)

You can specify a type for the property using `@var` annotation variable, so setter will take only a value of this type, else it will throw an exception. The code below will work similar as `public function setSomeProperty(stdClass $value){}`

```
/**
 * Should be an instance of stdClass only.
 *
 * @var \stdClass
 */
protected $shouldBeStdClass;
```

---

```
/**
 * Should be an array only.
 *
 * @var Array
 */
protected $shouldBeArray;
```

---

```
/**
 * Should be a string only
 *
 * @var String
 */
protected $shouldBeString;
```

---

```
/**
 * Should be a number only.
 *
 * @var Number
 */
protected $shouldBeNumber;
```

---

```
/**
 * Should be an object only.
 *
 * @var Object
 */
protected $shouldBeObject;
```

Notes
-----

[](#notes)

GetSetGo assumes that you use proper camelCase. So name your properties like `$pdoInstance` (not `$PDOInstance`) and call `setPdoInstance()` method.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

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

4701d ago

### Community

Maintainers

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

---

Tags

traitgettersetter

### Embed Badge

![Health badge](/badges/usmanhalalit-get-set-go/health.svg)

```
[![Health](https://phpackages.com/badges/usmanhalalit-get-set-go/health.svg)](https://phpackages.com/packages/usmanhalalit-get-set-go)
```

###  Alternatives

[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)
