PHPackages                             naghashyan/ngs-state-manager - 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. [Framework](/categories/framework)
4. /
5. naghashyan/ngs-state-manager

ActiveLibrary[Framework](/categories/framework)

naghashyan/ngs-state-manager
============================

Manage DTOs state change functional

1.0.0(4y ago)031MITPHPPHP &gt;=7.3.0

Since Nov 16Pushed 4y ago2 watchersCompare

[ Source](https://github.com/naghashyan/ngs-state-manager)[ Packagist](https://packagist.org/packages/naghashyan/ngs-state-manager)[ Docs](https://ngsframework.com)[ RSS](/packages/naghashyan-ngs-state-manager/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

ngs-state-manager
=================

[](#ngs-state-manager)

Naghashyan State Management Library

This library used for help state management, it will control if object state can be changed from X -&gt; Y. To create state manager instance you should use NgsStateManagerFactory. It has 2 static methods:

1. createJsonStateManager
=========================

[](#1-createjsonstatemanager)

This function should get 2 parameters: $statesConfigs, $ngsStateableMapper $statesConfigs is array which will help to library to understand which next states has current state, and who can change state $statesConfigs structure should be like this:

```
[
  "states" => [
    [
      "name" => "state1",   // the name of state, for changing state you should pass name of state as an expecting state change
      "description" => "desc1", // the description of state
      "nextStates" => [   //nextStates - is array which informs about possible states which can be changed from state 'state1'
        [
          "name" => "state2", // possible change state name
          "userGroups" => ["userGroup1", "userGroup2"] // user goups list who can change to this state
        ],
        [
          "name" => "state3",
          "userGroups" => ["userGroup1"]
        ]
      ],
      "beforeActions": ["URL1", "URL2"],  //list of urls which will be called before state change functional
      "afterActions": ["URL3"] //list of urls which will be called after state change functional
    ],
    [
      "name" => "state2",
      "description" => "desc2",
      "nextStates" => [
        {
          "name" => "state3",
          "userGroups" => ["userGroup2"]
        }
      ],
      "beforeActions" => [],
      "afterActions" => ["URL3"]
    ],
    [
      "name" => "state3",
      "description" => "desc3",
      "nextStates" => [],
      "beforeActions" => ["URL4"],
      "afterActions" => []
    ]
  ]
]

$ngsStateableMapper is mapper of object, to work with this library, mapper should implement INgsStateableMapper interface

createJsonStateManager function after call will return instance of NgsJsonStateManager which has method changeState($stateableDto, string $newStateName, string $userGroup)
$stateableDto is dto object which should implement INgsStateableDto interface

changeState method will return boolean if state changed or not or can throw exception NgsStateException

```

2. createDbStateManager
=======================

[](#2-createdbstatemanager)

This function should get $ngsStateableMapper as parameter $ngsStateableMapper is mapper of object, to work with this library, mapper should implement INgsStateableMapper interface

createDbStateManager function after call will return instance of NgsDBStateManager this manager to understand state change ruls uses table ngs\_states the row of table should has this columns:

name - name of state description - description of state next\_states - json which has same structure as 'nextStates' described above before\_actions - json array of urls which will be called before state change functional after\_actions - json array of urls which will be called after state change functional

NgsDBStateManager has method changeState($stateableDto, string $newStateName, string $userGroup) $stateableDto is dto object which should implement INgsStateableDto interface

changeState method will return boolean if state changed or not or can throw exception NgsStateException

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

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

1636d ago

### Community

Maintainers

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

---

Top Contributors

[![MikaelMkrtchyan123](https://avatars.githubusercontent.com/u/25316623?v=4)](https://github.com/MikaelMkrtchyan123 "MikaelMkrtchyan123 (6 commits)")[![znaghash](https://avatars.githubusercontent.com/u/3223442?v=4)](https://github.com/znaghash "znaghash (1 commits)")

---

Tags

frameworkstate-manager

### Embed Badge

![Health badge](/badges/naghashyan-ngs-state-manager/health.svg)

```
[![Health](https://phpackages.com/badges/naghashyan-ngs-state-manager/health.svg)](https://phpackages.com/packages/naghashyan-ngs-state-manager)
```

###  Alternatives

[hemp/presenter

Easy Model Presenters in Laravel

247592.6k1](/packages/hemp-presenter)[pestphp/pest-plugin-stressless

Stressless plugin for Pest

67792.6k16](/packages/pestphp-pest-plugin-stressless)[wpstarter/framework

The WpStarter Framework - Laravel Framework for WordPress

1810.1k4](/packages/wpstarter-framework)

PHPackages © 2026

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