Skip to content

O Configs

You can add and manage options within the configs and overwrite the application configs without having to change the values inside the config files.

Install for laravel

bash
composer require obelaw/o-configs

Migrate configs table

bash
php artisan migrate

Overwrite app configs

You can overwrite app configs

php
oconfig()->get('app.name') // Laravel;

oconfig()->set('app.name', 'Obelaw');
oconfig()->get('app.name') // Obelaw;

Usage

You can manage options in a simple way with helpers.

Add Option

You can add an option through the following line

php
oconfig()->set($path, $value);

$path: The option path that you will use to fetch its value.

$value: Put the value of any type of data.

If this path exists on config files It will be overwritten without modifying the value inside the file.

Get Option

Fetching value for a specific option

php
oconfig()->get($path, $default = null)

If this path does not exist in the configs table, the value will be fetched from within the file, otherwise, the default value will be displayed if you set.

$path: The option path.

$default: You can specify a default value if the option is not found.

Has Option

Make sure the option is there

php
oconfig()->has($path)

$path: The option path.

Verify that the value exists within the configs table.

Forget Option

You can delete any option

php
oconfig()->forget($path)

$path: The option path.

Delete the option from the configs table if it exists.

Use helpers

php
oconfig([$path => $value]); // set
oconfig($path, $default = null); // get
oconfig()->has(); // has
oconfig()->forget(); // forget

Use facade

php
use Obelaw\Configs\Facade\OConfig;

OConfig::set($path, $value);
OConfig::get($path, $default = null);
OConfig::has($path);
OConfig::forget($path);