https://github.com/overtrue/laravel-options
Global options module for Laravel application.
https://github.com/overtrue/laravel-options
laravel-options options settings
Last synced: 8 months ago
JSON representation
Global options module for Laravel application.
- Host: GitHub
- URL: https://github.com/overtrue/laravel-options
- Owner: overtrue
- License: mit
- Created: 2019-03-27T06:12:38.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-02T21:55:23.000Z (about 1 year ago)
- Last Synced: 2025-01-26T01:11:23.677Z (8 months ago)
- Topics: laravel-options, options, settings
- Language: PHP
- Size: 45.9 KB
- Stars: 52
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Options
Global options module for Laravel application.



[](https://github.com/sponsors/overtrue)
## Installation
You can install the package via composer:
```bash
composer require overtrue/laravel-options
```### Publish configuration and migrations
```bash
$ php artisan vendor:publish --provider="Overtrue\LaravelOptions\OptionsServiceProvider"
```### Run migrations
```bash
$ php artisan migrate
```## Usage
```php
// set
\Option::set('foo', 'bar');
\Option::set(['foo' => 'bar', 'bar' => 'baz']);// get
\Option::get('foo'); // bar
\Option::get(['foo', 'bar']); // ['foo' => 'bar', 'bar' => 'baz']
\Option::all(['foo', 'bar']); // ['foo' => 'bar', 'bar' => 'baz']// get all
\Option::get();
// or
\Option::all();// check exists
\Option::has('foo'); // true\Option::remove('foo');
\Option::remove(['foo', 'bar']);
```### Console commands
It is also possible to set options within the console:
```bash
php artisan option:set {key} {value}
```### Events
- `\Overtrue\LaravelOptions\Events\OptionCreated::class`
- `\Overtrue\LaravelOptions\Events\OptionUpdated::class`
- `\Overtrue\LaravelOptions\Events\OptionSaved::class`
- `\Overtrue\LaravelOptions\Events\OptionDeleted::class`
- `\Overtrue\LaravelOptions\Events\OptionRetrieved::class`
- `\Overtrue\LaravelOptions\Events\Event::class`## Testing
```bash
$ composer test
```## :heart: Sponsor me
[](https://github.com/sponsors/overtrue)
如果你喜欢我的项目并想支持它,[点击这里 :heart:](https://github.com/sponsors/overtrue)
## Project supported by JetBrains
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
[](https://www.jetbrains.com/?from=https://github.com/overtrue)
## Contributing
You can contribute in one of three ways:
1. File bug reports using the [issue tracker](https://github.com/overtrue/laravel-options/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/overtrue/laravel-options/issues).
3. Contribute new features or update the wiki._The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable._
## PHP 扩展包开发
> 想知道如何从零开始构建 PHP 扩展包?
>
> 请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package)## License
MIT