Download the PHP package rudnev/laravel-settings without Composer

On this page you can find all versions of the php package rudnev/laravel-settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-settings

Laravel Settings

Build Status StyleCI License: MIT Laravel Octane Compatible

Persistent settings for Laravel Framework

Requirements

Basic usage

Retrieve and store data using the global settings function:

You can also use the Settings facade:

And if you prefer contracts, you can use Method dependency injection:

Getting started

Installation
API
Scopes
Translation
Cache
Events
Custom store


Installation

You can install the package via composer:

Publish the migration with:

After the migration has been published you can create the settings table by running the migrations:

API

Check the value

Determine if an item exists in the settings store.

Get the value

Retrieve an item from the settings store by key.

Get multiple values

Retrieve multiple items from the settings store by key. Items not found in the settings store will have a null value.

Get all values

Get all the settings items.

Set the value

Store an item in the settings store.

Set multiple values

Store multiple items in the settings store.

Remove the value

Remove an item from the settings store.

Remove multiple values

Remove multiple items from the settings store.

Remove all values

Remove all items from the settings store.

Dot Notation

You can use dot syntax to indicate the item depth:

Scopes

If you want to have settings for your model you can use scope method:

But instead, it's better to use the Rudnev\Settings\Traits\HasSettings trait, for example:

Now you can use settings property to set and get values:

Also, settings method provides direct access to the settings store (but model state will not be updated):

To set the default settings define $settingsConfig property as array with default key:

And if you want specify the store from config/settings.php, use store option:

In addition to the scopes for models, you can freely create scopes for your application settings, for example:

Translation

I suggest using the built-in laravel methods to translate any keys, names and descriptions. You can use this approach for most laravel packages, there is no need to store translations within different database tables when you can do this in one place.

For example, create a file resources/lang/en/settings.php:

And get translated strings:

Cache

Cache is enabled by default, you can change this in your config/settings.php file.

To clear the cache you can run the following Artisan command:

Note: this command does not actually delete cache entries, it only invalidates them by changing the prefix for keys. If you are using settings for models, the cache can grow quickly. For this reason, it is recommended to use drivers that support eviction policies, such as redis, or use the command php artisan cache:clear to completely clear the cache.

Events

Events are triggered if this is not disabled via config (enabled by default).

Event Description
\Rudnev\Settings\Events\PropertyWritten Fired after the value is written to the store.
\Rudnev\Settings\Events\PropertyReceived Fired after the value is retrieved from the store.
\Rudnev\Settings\Events\PropertyMissed Fired if the item not found or is not set.
\Rudnev\Settings\Events\PropertyRemoved Fired after the item is removed from the store.
\Rudnev\Settings\Events\AllSettingsReceived Fired after retrieving all items from the store.
\Rudnev\Settings\Events\AllSettingsRemoved Fired after removing all items from the store.

Custom Store

To create your own store, you must use the extend method on the SettingsManager, which is used to bind a custom driver resolver to the manager, but first you need implement the StoreContract:

After that, to register a new settings driver named "mongo", you would do the following:

The first argument passed to the extend method is the name of the driver. This will correspond to your driver option in the config/settings.php configuration file. The second argument is a Closure that should return an Rudnev\Settings\Repository instance. The Closure will be passed an $app instance, which is an instance of Illuminate\Foundation\Application and a service container.

The call to Settings::extend could be done in the boot method of the default App\Providers\AppServiceProvider that ships with fresh Laravel applications, or you may create your own service provider to house the extension.

Finally, you can access your store as follows:

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-settings with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1|^8.0
ext-json Version *
illuminate/contracts Version ^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/database Version ^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/events Version ^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rudnev/laravel-settings contains the following files

Loading the files please wait ....