PHPackages                             coderatio/ngstates - 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. [Database &amp; ORM](/categories/database)
4. /
5. coderatio/ngstates

ActiveLibrary[Database &amp; ORM](/categories/database)

coderatio/ngstates
==================

A stand-alone database of Nigeria states and local government manager written for php developers

0.1(8y ago)14379MITPHPPHP &gt;=5.6

Since Jun 6Pushed 8y agoCompare

[ Source](https://github.com/coderatio/ngstates)[ Packagist](https://packagist.org/packages/coderatio/ngstates)[ RSS](/packages/coderatio-ngstates/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

NGstates
========

[](#ngstates)

A stand-alone database of Nigeria states and local government manager written for php developers.

Download
========

[](#download)

`composer require coderatio/ngstates` or clone this repo to use it mannually. *We don't recommend manual download.*

What you can do with it.
------------------------

[](#what-you-can-do-with-it)

1. Add states
2. Add state
3. Add state local governments
4. Add state local government
5. Get all states
6. Get state
7. Get state local governments
8. Get state local government
9. Update state
10. Update state local governments
11. Update state local government
12. Delete state
13. Delete state local government

Usage
-----

[](#usage)

```
// If you downloaded the library using composer
require 'vendor/autoload.php';

// If you didn't download the library via composer.
require 'pathto/src/helpers.php';
require 'pathto/src/NGStates.php';

$ngStates = new Coderatio\NGStates\NGStates();
/*
* Note: You can use the helper function which is an instance of NGStates::class.
* e.g ngstates()->getStates();
*/

print_r($ngStates->getStates()); // Print all the states
exit;
```

### Fetch records

[](#fetch-records)

```
// Get states
$ngStates->getStates();

// This will return an array of all states.
```

```
// Get State
$ngStates->getState(string|int $stateNameOrId);

// e.g
$ngStates->getState(26);

// OR
$ngStates->getState('Nasarawa State');
```

```
// Get state local governments
$ngStates->getStateLocals(string|int $stateNameOrId);

// e.g
$ngStates->getStateLocals(26);

// OR
$ngStates->getStateLocals('Nasarawa State');
```

```
// Get state local government
$ngState->getStateLocal(string|int $stateNameOrId, string|int $localNameOrId);

// e.g
$ngStates->getStateLocal(26, 1);

// OR
$ngStates->getStateLocal('Nasarawa State', 'Lafia');
```

### Add new records

[](#add-new-records)

```
// Add multiple states to database
$ngStates->addStates(array $statesData);

// e.g
$ngStates->addStates([
    ['state' => [
        'id' => 38,
        'name' => 'Demo State'
        'locals' => [
            'id' => 1,
            'name' => 'Demo LGA One'
        ]
    ]],
    ['state' => [
        'id' => 39,
        'name' => 'Demo State Two'
        'locals' => [
            'id' => 1,
            'name' => 'Demo LGA One'
        ]
    ]],
]);
```

```
// Add a state
$ngStates->addState(array $stateData);

// e.g
$ngStates->addState([
  'id' => 38,
  'name' => 'Demo State',
  'locals' => [
    [
      'id' => 1,
      'name' => 'Demo LGA One'
    ],
    [
      'id' => 2,
      'name' => 'Demo LGA Two',
    ]
  ]
]);
```

```
// Add state local governments
$ngStates->addStateLocals(string|int $stateNameOrId, array $localsData);

// e.g
$ngStates->addStateLocals(38, [
    [
        'id' => 3,
        'name' => 'Demo LGA Three',
    ],
    [
        'id' => 4,
        'name' => 'Demo LGA Four'
   ]
]);
```

```
// Add single local government
$ngStates->addStateLocal(string|int $stateNameOrId, array $localData);

// e.g
$ngStates->addStateLocal(38, [
    'id' => 5,
    'name' => 'Demo LGA Five'
]);
```

### Update records

[](#update-records)

```
// Update state
$ngStates->updateState(string|int $stateNameOrId, array $stateData);

// e.g
$ngStates->updateState(38, [
    'name' => 'Demo State Edited',
    'locals' => [
        [
            'id' => 1,
            'name' => 'Demo LGA One Edited'
        ]
    ]
]);
```

```
// Update state local governments
$ngStates->updateStateLocals(string|int $stateNameOrId, array $localsData);

// e.g
$ngStates->updateStateLocals(38, [
    [
        'id' => 1,
        'name' => 'Demo LGA One Updated'
    ],
    [
        'id' => 2,
        'name' => 'Demo LGA Two Updated'
    ]
]);
```

```
// Update state local
$ngStates->updateStateLocal(string|int $stateNameOrId, array $localData);

// e.g
$ngStates->updateStateLocal(38, [
    [
        'id' => 1,
        'name' => 'Demo LGA Changed'
    ]
]);
```

### Delete records

[](#delete-records)

```
// Delete state
$ngStates->deleteState(int $stateNameOrId);

// e.g
$ngStates->deleteState(38);
```

```
// Delete state local government
$ngStates->deleteStateLocal(string|int $stateNameOrId, int $stateLocalId);

// e.g
$ngStates->deleteStateLocal(38, 1); // Will delete local government with the ID 1.
```

Contribution
------------

[](#contribution)

To contribute, kindly fork the repo and send a pull request or find me on [Twitter](https://twitter.com/josiahoyahaya).

Licence
-------

[](#licence)

This project is licenced under MIT License. Read through the [license here](https://github.com/coderatio/ngstates/blob/master/LICENSE).

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2946d ago

### Community

Maintainers

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

---

Top Contributors

[![coderatio](https://avatars.githubusercontent.com/u/36877085?v=4)](https://github.com/coderatio "coderatio (8 commits)")

### Embed Badge

![Health badge](/badges/coderatio-ngstates/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M114](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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