PHPackages                             saxulum/saxulum-accessor - 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. saxulum/saxulum-accessor

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

saxulum/saxulum-accessor
========================

Saxulum Accessor

2.0.3(10y ago)04422MITPHPPHP &gt;=5.4

Since Sep 20Pushed 8y agoCompare

[ Source](https://github.com/saxulum-legacy/saxulum-accessor)[ Packagist](https://packagist.org/packages/saxulum/saxulum-accessor)[ RSS](/packages/saxulum-saxulum-accessor/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (6)Versions (19)Used By (0)

saxulum-accessor
================

[](#saxulum-accessor)

[![Build Status](https://camo.githubusercontent.com/f11f220ba937ca31abba7e0a24acdc5caf5c048a387b37a09e60de8fc35def41/68747470733a2f2f6170692e7472617669732d63692e6f72672f736178756c756d2f736178756c756d2d6163636573736f722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/saxulum/saxulum-accessor)[![Total Downloads](https://camo.githubusercontent.com/d5a8217f2c57edb76e261be8a7dce912b63d4fe1bdecc8cafd15b47d8ad8cb66/68747470733a2f2f706f7365722e707567782e6f72672f736178756c756d2f736178756c756d2d6163636573736f722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/saxulum/saxulum-accessor)[![Latest Stable Version](https://camo.githubusercontent.com/bdb0895c105700c7edc236e0025711bb45794ac4100ec0c15c5f4a3c03122091/68747470733a2f2f706f7365722e707567782e6f72672f736178756c756d2f736178756c756d2d6163636573736f722f762f737461626c652e706e67)](https://packagist.org/packages/saxulum/saxulum-accessor)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/af98938e349adb3c9fdd46af1227f9fbee43013a6f574a9e809a31736b52ed6d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736178756c756d2f736178756c756d2d6163636573736f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/saxulum/saxulum-accessor/?branch=master)

Features
--------

[](#features)

- Contains a [accessor trait](https://github.com/saxulum/saxulum-accessor/blob/master/src/Saxulum/Accessor/AccessorTrait.php) which allows to register accessors
- Contains a [add accessor](https://github.com/saxulum/saxulum-accessor/blob/master/src/Saxulum/Accessor/Accessors/Add.php), which means you don't have to write simple adders anymore
- Contains a [get accessor](https://github.com/saxulum/saxulum-accessor/blob/master/src/Saxulum/Accessor/Accessors/Get.php), which means you don't have to write simple getters anymore
- Contains a [is accessor](https://github.com/saxulum/saxulum-accessor/blob/master/src/Saxulum/Accessor/Accessors/Is.php), which means you don't have to write simple is anymore
- Contains a [remove accessor](https://github.com/saxulum/saxulum-accessor/blob/master/src/Saxulum/Accessor/Accessors/Remove.php), which means you don't have to write simple removers anymore
- Contains a [set accessor](https://github.com/saxulum/saxulum-accessor/blob/master/src/Saxulum/Accessor/Accessors/Set.php), which means you don't have to write simple setters anymore

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

[](#requirements)

- PHP 5.4+

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

[](#installation)

Through [Composer](http://getcomposer.org) as [saxulum/saxulum-accessor](https://packagist.org/packages/saxulum/saxulum-accessor).

### Bootstrap:

[](#bootstrap)

```
AccessorRegistry::registerAccessor(new Add());
AccessorRegistry::registerAccessor(new Get());
AccessorRegistry::registerAccessor(new Is());
AccessorRegistry::registerAccessor(new Remove());
AccessorRegistry::registerAccessor(new Set());

```

Usage
-----

[](#usage)

```
/**
 * @method string getName()
 * @method $this setName(string $name)
 * @method bool isActive()
 * @method $this setActive(bool $active)
 * @method $this addManies(Many $manies)
 * @method Many[] getManies()
 * @method $this removeManies(Many $manies)
 */
class One
{
    use AccessorTrait;

    /**
     * @var string
     */
    protected $name;

    /**
     * @var bool
     */
    protected $active;

    /**
     * @var Many[]
     */
    protected $manies = array();

    protected function _initProps()
    {
        $this
            ->_prop((new Prop('name', Hint::STRING))
                ->method(Get::PREFIX)
                ->method(Set::PREFIX)
            )
            ->_prop((new Prop('active', Hint::BOOL))
                ->method(Is::PREFIX)
                ->method(Set::PREFIX)
            )
            ->_prop((new Prop('manies', 'Many[]', true, 'one', Prop::REMOTE_ONE))
                ->method(Add::PREFIX)
                ->method(Get::PREFIX)
                ->method(Remove::PREFIX)
            )
        ;
    }
}

/**
 * @method string getName()
 * @method $this setName(string $name)
 * @method One getOne()
 * @method $this setOne(One $name)
 */
class Many
{
    use AccessorTrait;

    /**
     * @var string
     */
    protected $name;

    /**
     * @var One
     */
    protected $one;

    protected function _initProps()
    {
        $this
            ->_prop((new Prop('name', Hint::STRING))
                ->method(Get::PREFIX)
                ->method(Set::PREFIX)
            )
            ->_prop((new Prop('one', 'One', true, 'manies', Prop::REMOTE_MANY))
                ->method(Add::PREFIX)
                ->method(Get::PREFIX)
                ->method(Remove::PREFIX)
            )
        ;
    }
}

$one = new One();
$one
    ->setName('one')
    ->setActive(true)
;

$many = new Many();
$many
    ->setName('many')
    ->setOne($one)
;

$one->getName(); // return: string 'one'
$one->isActive(); // return: bool true
$one->getManies(); // return: an array with one instance of 'Many'

```

### PhpDoc generation

[](#phpdoc-generation)

Call the method `_generatePhpDoc` on the object using it

```
$one = new One();
$one->_generatePhpDoc()

```

Arguments
---------

[](#arguments)

### Pros:

[](#pros)

- less own code to write
- less owm code to debug
- scalar type hints
- handles bidirection relations

### Cons:

[](#cons)

- `@method` phpdoc, needs manually call `_generatePhpDoc()`
- slower (no benchmark)
- more complex to debug
- `method_exists` does not work

FAQ
---

[](#faq)

#### Does it work with doctrine [orm](https://github.com/doctrine/doctrine2)/[odm](https://github.com/doctrine/mongodb-odm) (proxy)

[](#does-it-work-with-doctrine-ormodm-proxy)

Yes it does, thx to [\_\_call](https://github.com/saxulum/saxulum-accessor/blob/master/src/Saxulum/Accessor/AccessorTrait.php#L33)

#### Does ist work with [symfony/property-access](https://github.com/symfony/PropertyAccess) ([symfony/form](https://github.com/symfony/Form))

[](#does-ist-work-with-symfonyproperty-access-symfonyform)

Yes it does, thx to [\_\_get](https://github.com/saxulum/saxulum-accessor/blob/master/src/Saxulum/Accessor/AccessorTrait.php#L45), [\_\_set](https://github.com/saxulum/saxulum-accessor/blob/master/src/Saxulum/Accessor/AccessorTrait.php#L58)

#### Does it work with [twig](http://twig.sensiolabs.org)

[](#does-it-work-with-twig)

Yes it does, thx to the plain [property method call wrapper](https://github.com/saxulum/saxulum-accessor/blob/master/src/Saxulum/Accessor/AccessorTrait.php#L76)

Copyright
---------

[](#copyright)

- Dominik Zogg

Contributors
------------

[](#contributors)

- Dominik Zogg
- Patrick Landolt

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

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

Recently: every ~87 days

Total

18

Last Release

3892d ago

Major Versions

1.1.1 → 2.0.0-beta12014-09-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/55048de83ca5e5d8c67164a19c78edcaad413b0c1a4ae10d92edf8d77bedd90f?d=identicon)[dominikzogg](/maintainers/dominikzogg)

---

Top Contributors

[![dominikzogg](https://avatars.githubusercontent.com/u/1011217?v=4)](https://github.com/dominikzogg "dominikzogg (134 commits)")

---

Tags

classaccessorsaxulum

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/saxulum-saxulum-accessor/health.svg)

```
[![Health](https://phpackages.com/badges/saxulum-saxulum-accessor/health.svg)](https://phpackages.com/packages/saxulum-saxulum-accessor)
```

###  Alternatives

[nette/robot-loader

🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.

89152.7M320](/packages/nette-robot-loader)[classpreloader/classpreloader

Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case

37642.4M32](/packages/classpreloader-classpreloader)[yzen.dev/plain-to-class

Class-transformer to transform your dataset into a structured object

16293.9k6](/packages/yzendev-plain-to-class)[ph-7/qrcode-generator-php-class

Light QRCode PHP class (library). QR Code Generator using vCard 4.0 and the Google Chart AP

10415.5k2](/packages/ph-7-qrcode-generator-php-class)[classpreloader/console

Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case

10235.0k5](/packages/classpreloader-console)[teknoo/states

Library to create classes following the State pattern in PHP. This can be a cleaner way for an object to change its behavior at runtime without resorting to large monolithic conditional statements and this improve maintainability and workflow writing.

1138.5k18](/packages/teknoo-states)

PHPackages © 2026

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