PHPackages                             nzsakib/db-config - 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. nzsakib/db-config

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

nzsakib/db-config
=================

Package for storing config details in database

00JavaScriptCI failing

Since Jan 4Pushed 6y ago1 watchersCompare

[ Source](https://github.com/nzsakib/db-config)[ Packagist](https://packagist.org/packages/nzsakib/db-config)[ RSS](/packages/nzsakib-db-config/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Very short description of the package
=====================================

[](#very-short-description-of-the-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/152516e7465c2bb8c4e4774a919bb0ee9e248d5c5a3a3c7e6ece98c214022495/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e7a73616b69622f64622d636f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nzsakib/db-config)[![Build Status](https://camo.githubusercontent.com/2482759c3dbd407fe8365ece3d63a5fe256d94548f881d785fe3980e533fe56d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6e7a73616b69622f64622d636f6e6669672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/nzsakib/db-config)[![Quality Score](https://camo.githubusercontent.com/0baa41c4711e925d7696352480bc747e748c6013058a9bbad6c3c6031d499319/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6e7a73616b69622f64622d636f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/nzsakib/db-config)[![Total Downloads](https://camo.githubusercontent.com/6459e03187a04f4071f8484dd12fc22152bf3a28c7e9f76f1161c4c7348365b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e7a73616b69622f64622d636f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nzsakib/db-config)

This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.

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

[](#installation)

You can install the package via composer:

```
composer require nzsakib/db-config
```

Usage
-----

[](#usage)

#### Facade or Implementation Class?

[](#facade-or-implementation-class)

You can either use facade or direct implementation class to work.

```
// You can use following facade
\Nzsakib\DbConfig\Facades\CustomConfig::getCollection();
// Or you can use the implementation below
(new \Nzsakib\DbConfig\DbConfig())->getCollection();
```

#### Get All Configurations as collection from DB

[](#get-all-configurations-as-collection-from-db)

```
use Nzsakib\DbConfig\DbConfig;

$config = new DbConfig;
$allConfig = $config->getCollection(); // returns Model collection of specified table

// pass to blade or do your thing by looping
foreach($allConfig as $config) {
    dump($config->name);
    dump($config->value);
}
```

#### Set a new config

[](#set-a-new-config)

```
use Nzsakib\DbConfig\DbConfig;

$config = new DbConfig;
$name = 'facebook';
$value = [
    'client_id' => 'a client id',
    'client_secret' => 'client secret',
];
// Value could be any data type e.g. boolean/array/string/integer

try {
    $newConfig = $config->set($name, $value);
    // new config is set and cache is invalidated
} catch (\InvalidArgumentException $e) {
    // redirect with message $e->getMessage()
}
```

#### Update existing DB config

[](#update-existing-db-config)

Cache will be deleted automatically after successfull update.

```
use Nzsakib\DbConfig\DbConfig;
use Illuminate\Database\Eloquent\ModelNotFoundException;

$config = new DbConfig;

$name = 'facebook';
$newValue = [
    'client_id' => 'updated client id',
    'client_secret' => 'updated secret'
];

try {
    $updatedConfig = (new DbConfig)->updateByName($name, $newValue);
    // Updated model is returned
} catch (ModelNotFoundException $e) {
    // Specified name does not exists in database
}

// Or you could update by `id` which is primary key
try {
    $updatedConfig = (new DbConfig)->updateById($id, $name, $newValue);
    // Updated model is returned
} catch (ModelNotFoundException $e) {
    // Specified id does not exists in database
}
```

#### Delete a DB Config

[](#delete-a-db-config)

Cache will be deleted automatically after successfull delete.

```
use Nzsakib\DbConfig\DbConfig;
use Illuminate\Database\Eloquent\ModelNotFoundException;

$name = 'facebook';
try {
    $deletedConfig = (new DbConfig)->deleteByName($name);
    // deleted successfully
} catch (ModelNotFoundException $e) {
    // specified name does not exists in database
}

// Or delete the config by primary key `id`
$id = request('id');
try {
    $deletedConfig = (new DbConfig)->deleteById($id);
    // deleted successfully
} catch (ModelNotFoundException $e) {
    // specified id does not exists in database
}
```

#### Get Eloquent DB Query to Work With Data

[](#get-eloquent-db-query-to-work-with-data)

```
use Nzsakib\DbConfig\DbConfig;

$query = (new DbConfig)->getQuery();
// Returns Builder instance to underlying config table Model
// You can run custom query on it
$query->where('name', 'facebook')->delete();
// facebook config row is deleted from DB
```

Publish the package config and migration files
----------------------------------------------

[](#publish-the-package-config-and-migration-files)

```
php artisan vendor:publish --provider="Nzsakib\DbConfig\DbConfigServiceProvider" --tag="config"
php artisan vendor:publish --provider="Nzsakib\DbConfig\DbConfigServiceProvider" --tag="migrations"
```

You can change table name of the migration file, but make sure you mention the updated table name in the config file.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Nazmus Sakib](https://github.com/nzsakib)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

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.

### Community

Maintainers

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

---

Top Contributors

[![nzsakib](https://avatars.githubusercontent.com/u/8240768?v=4)](https://github.com/nzsakib "nzsakib (20 commits)")

---

Tags

configuration-managementdatabaseenvironmentlaravelphp

### Embed Badge

![Health badge](/badges/nzsakib-db-config/health.svg)

```
[![Health](https://phpackages.com/badges/nzsakib-db-config/health.svg)](https://phpackages.com/packages/nzsakib-db-config)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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