PHPackages                             surya/laravel-settings - 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. surya/laravel-settings

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

surya/laravel-settings
======================

A laravel package for manage your app settings

v1.2.2(6y ago)122MITPHPPHP &gt;=7.0CI failing

Since Feb 24Pushed 2y agoCompare

[ Source](https://github.com/suryaherdiyanto/laravel-settings)[ Packagist](https://packagist.org/packages/surya/laravel-settings)[ RSS](/packages/surya-laravel-settings/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (3)Versions (14)Used By (0)

Laravel Settings
================

[](#laravel-settings)

A laravel package for manage your app settings

---

Installation
============

[](#installation)

```
composer require surya/laravel-settings

```

This package require laravel 5.5 or higher, if your current version of laravel is below 5.5 you could install this package but it isn't tested at all.

Register the ServiceProvider in `config/app.php`

```
'providers' => [
    Surya\Setting\SettingServiceProvider::class,
]
```

Also register the Facade Alias

```
'aliases' => [
    'Setting' => Surya\Setting\Facades\Setting::class,
]
```

Publish migration table

```
php artisan vendor:publish --provider="Surya\Setting\SettingServiceProvider" --tag="migrations"

```

Migrate

```
php artisan migrate

```

Usage
=====

[](#usage)

By default the folder that use for store our setting is located in `resources/settings`, so you must create `settings` folder by your self.

Creating Setting File
---------------------

[](#creating-setting-file)

Let's create setting file call `general.php`

```
return [
    'site_name'     => [
        'type'      => 'text',
        'default'   => 'Laravel',
        'label'     => 'Site Name'
    ],
    'genre'         => [
        'type'      => 'radio',
        'default'   => 'male',
        'label'     => 'Genre',
        'options'   => [
            'male'      => 'Male',
            'female'    => 'Female'
        ]
    ]
]
```

> the filename of setting also refer to group, used for getting setting value and prop the setting file only containts an array of setting properties. the `site_name` is the key of the setting.

available setting properties:

1. type =&gt; the type of the setting, basically the input tag e.g: text, textarea, select, number, etc.
2. default =&gt; the default value of the setting.
3. label =&gt; the setting label.
4. options =&gt; this specific for type select and radio only.

Rendering Setting File
----------------------

[](#rendering-setting-file)

After the setting file was created. You can render the setting file by using blade directive

```
@rendersettings('general')
```

> the `@rendersettings` directive doesn't include the form tag, so you should render your setting between form tag

```

    {!! csrf_field() !!}
    @rendersettings('general')

```

All the setting type are bootstrap friendly so it will adapt to your bootstrap theme.

Saving Your Setting
-------------------

[](#saving-your-setting)

You can simply use facade to saving settings

```
use Setting;
use Illuminate\Http\Request;

class SettingController extends Controller
{
    public function save(Request $request)
    {
        Setting::save($request->except('_token'));
        return redirect('your.view');
    }
}
```

Play With Value
---------------

[](#play-with-value)

Getting Setting Value

---

There's three diffrent ways to getting setting value. use the directive

```
@settings('filename.key')

```

use the helper function

```
settings('group.key');
```

use the facade class

```
Setting::get('group.key');
```

getting setting propperty

---

```
Setting::getSettingProp('group.key.default')
```

or

```
setting('group.key.default')
```

checking if setting exists

```
Setting::exists('group', 'key)
```

or

```
settingExists('group', 'key')
```

Modify Setting Type
-------------------

[](#modify-setting-type)

You still has control for modify each of setting type or adding new setting type.

publish setting types view

```
php artisan vendor:publish --provider="Surya\Setting\SettingServiceProvider" --tag="views"

```

as you can see in `resources/view/vendor/setting/settings` each setting `type` view has exact name of `type` property, so if you want additional setting type just add another view file.

for example if you want create setting that accept email

```

    {{ $label }}

```

> all properties for each setting key are automatically passed. save as `email.blade.php` and it's automatically recognized as email setting type.

New In 1.2.+
------------

[](#new-in-12)

You can now add resource key for select setting type

for example, if you want select a primary user from database

```
return [
    'primary_user'    => [
        'type'  => 'select',
        'label' => 'Select a Primary User',
        'source'    => App\User::class,
        'show_label'     => 'email'
    ],
]
```

There are 3 new keys, `source` is the model source `show_label` model property `key` if your model primary key is `id` just leave it empty.

> currently the source key only work for `select` setting type

New in 1.2.1
------------

[](#new-in-121)

New `switch` setting type.

```
'example_switch'    => [
        'type'  => 'switch',
        'default'   => 0,
        'label' => 'Switch Example',
    ]
```

> in order to use switch use must include bootstrap otherwise you will get normal checkbox input

Now the setting type `check` can use `options` key

```
'includes'   => [
    'type'      => 'check',
    'default'   => ['logo', 'profile'],
    'label'     => 'Your website include: ',
    'options'   => [
        'profile'   => 'Your profile',
        'logo'      => 'Your logo',
        'identity'  => 'Your identity'
    ]
],
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity62

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

Recently: every ~401 days

Total

12

Last Release

907d ago

Major Versions

v1.2.2 → 2.0.x-dev2023-11-18

PHP version history (2 changes)v1.0.1PHP &gt;=7.0

2.0.x-devPHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![suryaherdiyanto](https://avatars.githubusercontent.com/u/28683066?v=4)](https://github.com/suryaherdiyanto "suryaherdiyanto (77 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/surya-laravel-settings/health.svg)

```
[![Health](https://phpackages.com/badges/surya-laravel-settings/health.svg)](https://phpackages.com/packages/surya-laravel-settings)
```

###  Alternatives

[ashallendesign/short-url

A Laravel package for creating shortened URLs for your web apps.

1.4k1.9M4](/packages/ashallendesign-short-url)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[illuminatech/balance

Provides support for Balance accounting system based on debit and credit principle

16137.4k](/packages/illuminatech-balance)[glhd/special

1929.4k](/packages/glhd-special)

PHPackages © 2026

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