定制 laravel-ready/env-profile-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

laravel-ready/env-profile-manager

Composer 安装命令:

composer require laravel-ready/env-profile-manager

包简介

Environment profile manager for Laravel applications

README 文档

README

Tests Latest Stable Version Total Downloads License

A Laravel package for managing multiple environment configurations (.env files) with an intuitive web interface. Easily switch between different environment profiles, create backups, and manage your application's configuration.

Features

  • 🔄 Multiple Environment Profiles: Create and manage multiple .env configurations
  • 🎨 Modern Web Interface: Vue 3 + Tailwind CSS interface with Monaco Editor
  • 🌓 Dark/Light Mode: Built-in theme support with system preference detection
  • 💾 Automatic Backups: Automatically backup .env files before changes
  • 🏷️ Application Names: Optionally tag profiles with application names
  • 🔒 Secure: Configurable middleware protection
  • 📦 Easy Installation: Simple composer installation with publish commands
  • 🚀 Laravel 10/11/12 Support: Compatible with latest Laravel versions
  • 🔌 API Support: RESTful API endpoints for programmatic access

Preview

Preview

Requirements

  • PHP 8.2 or higher
  • Laravel 10.0 or higher

Installation

  1. Install the package via Composer:
composer require laravel-ready/env-profile-manager
  1. Publish the package resources:
php artisan env-profile-manager:publish

Or publish specific resources:

# Publish config file
php artisan vendor:publish --tag=env-profile-manager-config

# Publish views (if you want to customize)
php artisan vendor:publish --tag=env-profile-manager-views

# Publish assets
php artisan vendor:publish --tag=env-profile-manager-assets

# Publish migrations
php artisan vendor:publish --tag=env-profile-manager-migrations
  1. Run the migrations:
php artisan migrate
  1. (Optional) Add CSRF token meta tag to your layout if not already present:
<meta name="csrf-token" content="{{ csrf_token() }}">

Configuration

The configuration file is published to config/env-profile-manager.php. Here are the available options:

return [
    // Web route prefix
    'route_prefix' => 'env-profile-manager',
    
    // API route prefix
    'api_prefix' => 'api/env-profile-manager',
    
    // Middleware for web routes
    'middleware' => ['web', 'auth'],
    
    // Middleware for API routes
    'api_middleware' => ['api', 'auth:sanctum'],
    
    // Layout to extend for views
    // Set to null to use the package's default layout
    // Example: 'layouts.app' to use your application's layout
    'layout' => 'env-profile-manager::layouts.default',
    
    // Maximum number of .env backups to keep
    'max_backups' => 10,
    
    // Enable/disable features
    'features' => [
        'api' => true,
        'web_ui' => true,
        'backups' => true,
    ],
];

Usage

Web Interface

After installation, navigate to /env-profile-manager (or your configured route prefix) to access the web interface.

Features available in the web interface:

  • View and edit current .env configuration
  • Create new profiles from current configuration
  • Load saved profiles
  • Activate profiles (overwrites current .env)
  • Delete profiles
  • Real-time syntax highlighting with Monaco Editor

API Endpoints

If API is enabled in configuration, the following endpoints are available:

  • GET /api/env-profile-manager - List all profiles and current .env content
  • POST /api/env-profile-manager - Create a new profile
  • GET /api/env-profile-manager/{id} - Get a specific profile
  • PUT /api/env-profile-manager/{id} - Update a profile
  • DELETE /api/env-profile-manager/{id} - Delete a profile
  • POST /api/env-profile-manager/{id}/activate - Activate a profile
  • GET /api/env-profile-manager/current-env - Get current .env content
  • PUT /api/env-profile-manager/current-env - Update current .env content

Programmatic Usage

You can also use the package programmatically:

use LaravelReady\EnvProfiles\Models\EnvProfile;
use LaravelReady\EnvProfiles\Services\EnvFileService;

// Create a new profile
$profile = EnvProfile::create([
    'name' => 'Production',
    'app_name' => 'My Laravel App',
    'content' => file_get_contents(base_path('.env.production')),
]);

// Activate a profile
$profile->activate();

// Use the EnvFileService
$envService = app(EnvFileService::class);
$currentEnv = $envService->read();
$envService->write($newContent);

Security Considerations

  1. Protect Routes: The package uses middleware configuration to protect routes. Make sure to configure appropriate middleware.

  2. Sensitive Data: Be careful when storing sensitive data in profiles. Consider encrypting sensitive values.

  3. Backups: The package automatically creates backups before modifying .env files. Configure max_backups to control disk usage.

Customization

Views

To customize the views, publish them and edit as needed:

php artisan vendor:publish --tag=env-profile-manager-views

Views will be published to resources/views/vendor/env-profile-manager/.

Extending the Layout

By default, the package uses its own layout (env-profile-manager::layouts.default). You can use your application's layout by changing the configuration:

'layout' => 'layouts.app',

Or set it to null to use the package's default layout:

'layout' => null,

If using a custom layout, make sure it has a @yield('content') section and includes the necessary @stack('styles') and @stack('scripts') directives.

Troubleshooting

Monaco Editor Not Loading

Make sure your layout includes the style and script stacks:

@stack('styles')
@stack('scripts')

CSRF Token Errors

Ensure your layout includes the CSRF token meta tag:

<meta name="csrf-token" content="{{ csrf_token() }}">

Permission Denied Errors

Check that the web server has write permissions for:

  • The .env file
  • The Laravel base directory (for creating backups)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This package is open-sourced software licensed under the MIT license.

laravel-ready/env-profile-manager 适用场景与选型建议

laravel-ready/env-profile-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 208 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 laravel-ready/env-profile-manager 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-12