Download the PHP package lysice/hyperf-user-settings without Composer

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

hyperf-user-settings

Simple user settings util for hyperf Settings are stored as JSON in a single database column, so you can easily add it to an existing table (users for example).

Installation

  1. Run composer require lysice/hyperf-user-settings to include this in your project.
  2. Run php bin/hyperf.php vendor:publish lysice/hyperf-use-settings to publish the config file and migration.
  3. Run php bin/hyperf.php migrate to add field to your table. Alternatively, use the Laravel migration included in this package to automatically create a settings column in the users table: php bin/hyperf.php migrate.
  4. Modify the published configuration file located at config/user-setting.php.

Configuration

There is a file config/user-setting.php to adjust package configuration. If this file doesn't exist, run php bin/hyperf.php vendor:publish to create the default configuration file.

Table

Specify the table on your database that you want to use.

Column

Specify the column in the above table that you want to store the settings JSON data in.

Constraint key

Specify the index column used for the constraint - this is used to differentiate between different users, objects or models (normally id).

Default constraint value

Specify the default constraint value - by default this will be the user's ID you need pass userId to the construct function, and will be superseded by specifying a $constraint_value on any function call.

Custom constraint

Specify a where clause for each query - set this if you do not want to access different rows (for example if your app is single-user only).

Usage

Use the helper function setting($userId) to initial the Setting class, and you can invoke any function in Setting class. The $constraint_value parameter is optional on all functions; if this is not passed, the default_constraint_value from the config file will be used.

Set

Use set to change the value of a setting. If the setting does not exist, it will be created automatically. You can set multiple keys at once by passing an associative (key=>value) array to the first parameter.

Get

Use get to retrieve the value of a setting. The second parameter is optional and can be used to specify a default value if the setting does not exist (the default default value is null).

Forget

Unset or delete a setting by calling forget.

Has

Check for the existence of a setting, returned as a boolean.

All

Retrieve all settings as an associative array (key=>value).

Save

Save all changes back to the database. This will need to be called after making changes; it is not automatic.

Load

Reload settings from the database. This is called automatically if settings have not been loaded before being accessed or mutated.

call chaining

The functions below return the object of setting so you can invoke other functions. set forget save like this:

Example

These examples are using the default configuration.

Using the default constraint value

The following sets and returns the currently logged in user's setting "example".

Finally

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 hyperf-user-settings with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
hyperf/framework Version >=2.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 lysice/hyperf-user-settings contains the following files

Loading the files please wait ....