Download the PHP package hackeresq/laravel-settings without Composer

On this page you can find all versions of the php package hackeresq/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

Settings

Latest Version on Packagist Total Downloads

Super simple key/value settings for Laravel that natively supports multi-tenancy.

Installation

This package can be used in Laravel 8.0+.

You can install the package via composer:

Since Laravel 5.5+, service providers and aliases will automatically get registered and you can skip this step. To use this package with older versions, please use release < 2.0.

You can publish the migration and config files, then migrate the new settings table all in one go, using:

Success! laravel-settings is now installed!

Usage

Settings can be accessed using the easy-to-remember Facade, Settings.

Set new setting

You can set new settings using the "set" method, which accepts an associative array of one or more key/value pairs. For security reasons, this will first check to see if such a setting key is "fillable," which is a configuration option in the config/settings.php file.

If such a key exists in the config, it will update the key to the new value passed. If the key does not exist in the fillable config, it will disregard the change. So, if this is a fresh install, do not expect the following to work:

It will not set the new setting until you have either set the fillable fields in the config, or you have opted to force the setting. If you wish to force set a new setting, you should use the force() method before calling the set() method:

As of version 3.0.4, the global override for forcing settings has been removed from the config file for this package. Instead, you can use a wildcard for the fillable property, like this:

This is more in line with standard Laravel syntax (e.g. for models).

Get all settings

If no parameters are passed to the "get" method, it will return an array of all settings:

You can optionally hide specific settings using the hidden config as described below.

Get single setting

You can return a single setting by passing a single setting key:

Get certain settings

You can also return a list of specified settings by passing an array of setting keys:

Check if a setting is set

Sometimes you can't know if a setting has been set or not (i.e. boolean settings that will return false if the setting does not exist, but also if the setting has been set to false).

Encryption

You can define keys that should be encrypted automatically within the config/settings.php file. To do so, add the keys as such:

Multi-tenancy

This package can be used in a multi-tenant environment. The has methods all read an internal 'tenant' attribute that can be set with the tenant() method. You can set the 'tenant' attribute by calling the tenant() method first, like this:

The 'tenant' attribute passed can be any alphanumeric string. The 'tenant' attribute can also be left blank to have, for example, settings saved to a so-called "central" tenant. Note: the 'tenant' attribute is not strictly typed, and will be passed to the database query as a string.

Casting

You can cast settings to native PHP types using the cast option in the settings.php config. Here's an example of an array being cast to JSON and back to a native PHP array:

Which allows you to do the following:

Disable cache

Depending on your use case, you may like to disable the cache (enabled by default). Disable the cache by modifying the config/settings.php file as such:

Hidden settings

You may wish to hide specific settings (like API keys or other sensitive user data) from inadvertent disclosure. You can set these settings in the config/settings.php file. To do so, add the keys as such:

Once these are set, they must be specifically requested using the get() method. In other words, this acts like the $hidden attribute on Laravel Eloquent models.

In addition to hiding specific settings, you can opt to hide ALL the settings (unless specifically requested, of course). To do this, you can use a wildcard:

Customize table name

For some cases, it may be necessary to customize the name of the table where settings are stored. By default, the migrations that come with this package create a 'settings' table. If, for some reason, it becomes necessary to change the default table, you can set the 'table' option in the config/settings.php file, like this:

This configuration option is not included in the base config file as this is an edge case that is not commonly encountered; but nonetheless a nice convenience to have when it does come up.

Finally

Testing

You can run tests with the composer test command.

Contributing

Feel free to create a fork and submit a pull request if you would like to contribute.

Bug reports

Raise an issue on GitHub if you notice something broken.


All versions of laravel-settings with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
laravel/framework Version ^8.0|^9.0|^10.0
doctrine/dbal Version ^3.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 hackeresq/laravel-settings contains the following files

Loading the files please wait ....