Download the PHP package bonsaicms/settings without Composer

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

Introduction

There are some "settings packages" for Laravel out there. For example anlutro/laravel-settings or akaunting/setting but we think we can do better.

For example, this package is able to save any value in the settings (numbers, strings, booleans etc. but also any objects, for example Eloquent models).

How it works

  1. This package serialize the setting value (using the PHP's serialize and base64_encode functions).
  2. The value is stored it in a text database column type (if you use DatabaseSettingsRepository).
  3. When reading the setting value, the serialized value is decoded (via PHP base64_decode function) and then deserialized (via PHP deserialize function).

Installation

Publish config file

Run migrations

Auto-load Middleware

Add the following line inside your app/Http/Kernel.php file. This middleware will automatically call Settings::all() before each request so whenever you call Settings::get() there will be no DB query executed, because all settings will be already in the cache.

Auto-save Middleware

Add the following line inside your app/Http/Kernel.php file. This middleware will automatically call Settings::save() after each request so you won't need to manually call it.

Usage

Set / Get Eloquent Models

To make this work, your models need to implement our BonsaiCms\Settings\Contracts\SerializationWrappable interface. You can implement serialization logic by yourself, but you can also use our BonsaiCms\Settings\Models\SerializableModelTrait trait.

Our BonsaiCms\Settings\Models\SerializableModelTrait will NOT serialize the model's attributes! It will only serialize the model identity (model name + ID) and it will retrieve that model from the database when you call Settings::get(...).

If you need different serialization behaviour you need to implement your own serialization logic by implementing our BonsaiCms\Settings\Contracts\SerializationWrappable interface.

Example of your model class

Has

Save

Delete

Artisan command to delete settings

This will call Settings::deleteAll() under the hood.

Facade vs Helper

There is also a settings() helper available.

Save your own objects in settings

Any of your classes can implement our BonsaiCms\Settings\Contracts\SerializationWrappable interface. It should then implement these two methods:

Example implementation:

Then you can simply write:

Settings and JSON-like API

Do you need to work with settings via API ? Check out our bonsaicms/settings-api package.

Testing


All versions of settings with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0.2
laravel/framework Version ^8.0|^9.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 bonsaicms/settings contains the following files

Loading the files please wait ....