sajadsdi/laravel-setting-pro
Composer 安装命令:
composer require sajadsdi/laravel-setting-pro
包简介
Easy settings management for laravel framework
README 文档
README
Laravel Setting Pro
Effortless Management of Laravel Application Settings.
Description
A Laravel package that provides a simple and effective way to handle application settings with support for persistent storage using both file-based and database drivers.
Features
The Laravel Setting Pro package simplifies application settings management in Laravel and provides these key features:
-
Flexible Storage: Choose between file-based or database storage to suit your application's needs.
-
Flexible Database: Choose between
mysqlormongodbor create own db connection for settings. -
Caching: Improve performance with automatic caching of settings. You can choose between
fileorredisor create own cache driver. -
Queue Support: Handle setting updates and deletes in the background, ensuring smooth user experiences.
-
Event Triggers: Respond to setting changes in real-time by leveraging Laravel events.
-
Global Helper Function & Facade: Access and manipulate settings anywhere in your laravel app with a simple
settingfunction orSettingfacade (even in the config files). -
Artisan Commands for Ease of Use: Publish configuration and migrations effortlessly with the
setting:publishartisan command; complete installations, migrations, and initial tests using thesetting:installcommand. -
Easy get & set and delete settings with dot notation:
get&set&deleteandhasoperations on nested settings keys. -
Easy import settings : Import settings from a driver to default store driver.
-
Auto create setting : you can use default value for get operation or set operation on any new setting name.
This package is designed for developers looking for an efficient and intuitive way to handle application settings. It offers the necessary tools while keeping the process simple and maintainable.
Requirements
- PHP ^8.1
- Laravel ^9.0|^10.0
Installation
Use Composer to install the package:
composer require sajadsdi/laravel-setting-pro
Setup
After the package installation, use the provided Artisan commands to publish configuration and migration files, and complete the installation process:
First, publish the configuration and migration files using:
php artisan setting:publish
This will publish _setting.php to your config folder and migration file.
Then, use the installation command to perform migrations and any necessary setup operations:
php artisan setting:install
These commands will set up your settings table in the database and ensure that the package is ready to use.
Usage
Two ways to use Laravel Setting Pro:
- Using the
settingfunction:
// Get a setting value $value = setting('my_setting')->get('key', 'default value'); //or $value = setting('my_setting','key', 'default value'); //or $value = setting()->select('my_setting')->get('key', 'default value'); // Set a setting value setting('my_setting')->set(['key' => 'value']); //or setting()->select('my_setting')->set(['key' => 'value']); //delete a key from setting setting('my_setting')->delete('key'); //or setting()->select('my_setting')->delete('key');
- Using the
Settingfacade:
<?php use Sajadsdi\LaravelSettingPro\Support\Setting; // Get a setting value $value = Setting::select('my_setting')->get('key', 'default value'); //or $value = Setting::my_setting()->get('key', 'default value'); //or $value = Setting::my_setting('key', 'default value'); // Set a setting value Setting::select('my_setting')->set('key', 'value'); //or Setting::my_setting()->set('key', 'value'); //delete key from setting Setting::select('my_setting')->delete('key'); //or Setting::my_setting()->delete('key'); //checking exists by has method if(Setting::select('my_setting')->has('key')){ echo "key exists!"; }else{ echo "key not exists!"; }
Advanced Usage
you can use set and get operation in any way as stated above, with dot notation and multiple keys and defaults like this:
//get operation $value = Setting::my_setting(['users.3.profile.pic','users.3.profile.name'], ["default.png","No name"]); //or multi keys and single defaults $value = setting('my_setting')->get(['users.3.profile.pic','users.3.profile.name'], ["no data"]); //set operation setting::select('my_setting')->set(['users.3.profile.pic' => "profile.png",'users.3.profile.name' => "john"]) //delete multiple keys setting::select('my_setting')->delete(['users.3.profile.pic','users.3.profile.name']); //multiple keys checking exists by has method if(Setting::select('my_setting')->has(['users.3.profile.pic','users.3.profile.name'])){ echo "The keys are exists!"; }else{ echo "The keys do not exist!"; } // it's very Easy
This package use Dot Notation Array package to getting keys and setting operations you can see Documentation to better use for Laravel Setting Pro
Caching
You can set config to enable setting cache, and you can choose cache driver for optimal performance. To clear the settings cache, use:
php artisan setting:clear-cache
Configuration
You can change _setting config on laravel config path.
For more details about Configuration Laravel Setting Pro , click here
Contributing
We welcome contributions from the community to improve and extend this library. If you'd like to contribute, please follow these steps:
- Fork the repository on GitHub.
- Clone your fork locally.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with clear, concise commit messages.
- Push your changes to your fork on GitHub.
- Submit a pull request to the main repository.
Reporting Bugs and Security Issues
If you discover any security vulnerabilities or bugs in this project, please let us know through the following channels:
-
GitHub Issues: You can open an issue on our GitHub repository to report bugs or security concerns. Please provide as much detail as possible, including steps to reproduce the issue.
-
Contact: For sensitive security-related issues, you can contact us directly through the following contact channels
Contact
If you have any questions, suggestions, financial, or if you'd like to contribute to this project, please feel free to contact the maintainer:
- Email: thunder11like@gmail.com
We appreciate your feedback, support, and any financial contributions that help us maintain and improve this project.
License
This package is open-sourced software licensed under the MIT license.
Made with ❤️ by SajaD SaeeDi.
sajadsdi/laravel-setting-pro 适用场景与选型建议
sajadsdi/laravel-setting-pro 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.29k 次下载、GitHub Stars 达 133, 最近一次更新时间为 2023 年 11 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「laravel」 「Settings」 「configs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sajadsdi/laravel-setting-pro 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sajadsdi/laravel-setting-pro 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sajadsdi/laravel-setting-pro 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Persistent settings package for Laravel framework.
A Zend Framework module to quickly and easily set PHP settings.
Settings Card for Laravel Nova.
Extends basic Wordpress features.
Simple ASCII output of array data
统计信息
- 总下载量: 6.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 133
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-08