承接 salehye/laravel-settings 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

salehye/laravel-settings

Composer 安装命令:

composer require salehye/laravel-settings

包简介

باكج احترافي متكامل لإدارة إعدادات المواقع في لارافل مع دعم الترجمة والتخزين المؤقت

README 文档

README

Laravel PHP MIT License

Salehye\LaravelSettings is a comprehensive Laravel package designed for flexible, extensible, multi-language, and enterprise-ready management of website settings. It provides a robust architecture based on Domain-Driven Design (DDD) principles, ensuring maintainability and scalability for your Laravel applications.

Features

  • Flexible: Easily define and manage various types of settings (string, integer, boolean, array, JSON, float).
  • Extensible: Designed with interfaces and services, allowing for easy customization and extension of core functionalities like caching and validation.
  • Multi-language Support: Built-in support for translating setting descriptions and values.
  • Enterprise-ready: Follows best practices for Laravel package development, including migrations, configuration, commands, and API endpoints.
  • Caching: Integrated caching mechanism to optimize performance for frequently accessed settings.
  • Validation: Custom validation rules can be defined for settings.
  • Artisan Commands: Convenient Artisan commands for installation and management.
  • API Endpoints: RESTful API for programmatic access and management of settings.
  • Facade & Helper: Easy access to settings via a Facade and a global helper function.

Installation

You can install the package via Composer:

composer require your-vendor/web-settings

After installing the package, you can publish its configuration and run the migrations using the web-settings:install Artisan command:

php artisan web-settings:install

This command will:

  • Publish the web-settings.php configuration file to your config directory.
  • Publish the migration file to your database/migrations directory.
  • Run the migrations to create the web_settings table.

Alternatively, you can publish the files manually:

php artisan vendor:publish --provider="Salehye\LaravelSettings\Providers\Salehye\LaravelSettingsServiceProvider" --tag="web-settings-config"
php artisan vendor:publish --provider="Salehye\LaravelSettings\Providers\Salehye\LaravelSettingsServiceProvider" --tag="web-settings-migrations"
php artisan migrate

Configuration

The config/web-settings.php file allows you to customize various aspects of the package:

// config/web-settings.php
return [
    'table_name' => 'web_settings',
    'cache' => [
        'enabled' => env('WEB_SETTINGS_CACHE_ENABLED', true),
        'duration' => env('WEB_SETTINGS_CACHE_DURATION', 60),
        'prefix' => env('WEB_SETTINGS_CACHE_PREFIX', 'web_settings_'),
    ],
    'validation' => [
        'rules' => [
            // 'app_name' => 'required|string|max:255',
        ],
    ],
    'defaults' => [
        // ['key' => 'app_name', 'value' => 'My Laravel App', 'type' => 'string', 'group' => 'general', 'description' => 'The name of the application'],
    ],
    'web_middleware' => ['web', 'auth'],
    'api_middleware' => ['api', 'auth:sanctum'],
    'localization' => [
        'enabled' => env('WEB_SETTINGS_LOCALIZATION_ENABLED', false),
        'locales' => ['en', 'ar'],
        'default_locale' => 'en',
    ],
];

Usage

Getting Settings

You can retrieve settings using the Settings Facade or the web_setting() helper function:

// Using the Facade
use Salehye\LaravelSettings\Support\Facades\Settings;

$appName = Settings::get('app_name', 'Default App Name');

// Using the helper function
$contactEmail = web_setting('contact_email', 'info@example.com');

// Get all settings
$allSettings = Settings::all();

Setting/Updating Settings

// Using the Facade
Settings::set('app_name', 'My New App Name', 'string', 'general', 'Updated application name');

// Using the helper function (if you need to set, call without arguments first)
web_setting()->set('contact_email', 'new_info@example.com', 'email', 'contact');

Deleting Settings

Settings::forget('old_setting_key');

API Endpoints

The package provides the following API endpoints (prefixed with /api/web-settings):

Method URI Action Middleware
GET / index api, auth:sanctum
GET /{key} show api, auth:sanctum
PUT /{key} update api, auth:sanctum
DELETE /{key} destroy api, auth:sanctum

Example API usage with PUT request:

curl -X PUT \
  http://your-app.com/api/web-settings/app_name \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_SANCTUM_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "value": "My Updated App",
    "type": "string",
    "group": "general",
    "description": "The updated name of the application"
  }'

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

License

The Salehye\LaravelSettings Laravel Package is open-sourced software licensed under the MIT license.

salehye/laravel-settings 适用场景与选型建议

salehye/laravel-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「admin」 「package」 「configuration」 「laravel」 「Settings」 「multi-language」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 salehye/laravel-settings 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 salehye/laravel-settings 我们能提供哪些服务?
定制开发 / 二次开发

基于 salehye/laravel-settings 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 22
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-15