mantraideas/laravel-env-doctor
Composer 安装命令:
composer require mantraideas/laravel-env-doctor
包简介
LaravelEnvDoctor is a developer-friendly CLI tool for Laravel that checks your .env variables, validates the current environment, and ensures directory permissions are correctly set — helping you catch misconfigurations before they become problems.
README 文档
README
Laravel Environment Doctor 🩺
A diagnostic tool that checks your Laravel application's environment configuration and directory permissions to prevent common deployment issues.
Version 1.0.5+ adds a File Existence Check — verify that critical files (
.env, SSL certificates, OAuth keys) exist, are readable, and have the correct permissions.
Features
- ✅ Checks for required
.envvariables - 🔒 Verifies directory permissions
- 📄 Checks that critical files exist and are readable (v1.0.5+)
- 📊 Provides a summary report
- 📝 Optional logging of results
- 🎨 Beautiful console output
Installation
Install via Composer:
composer require mantraideas/laravel-env-doctor
Publish the configuration file:
php artisan vendor:publish --provider="mantraideas\LaravelEnvDoctor\LaravelEnvDoctorServiceProvider"
Usage
Run the environment diagnosis:
php artisan env:doctor
Enable logging to a file:
php artisan env:doctor --log
Configuration
You can customize the configuration by publishing the config file:
<?php return [ /* |-------------------------------------------------------------------------- | Required Environment Variables |-------------------------------------------------------------------------- | | These are the essential environment variables your Laravel application | needs to function properly. The checker will verify they exist and | aren't empty. Default values are only for reference in the check. | */ 'required_env_keys' => [ 'APP_NAME', 'APP_ENV', 'APP_KEY', 'APP_DEBUG', 'APP_URL', 'APP_LOCALE', 'APP_FALLBACK_LOCALE', 'APP_FAKER_LOCALE', 'APP_MAINTENANCE_DRIVER', 'PHP_CLI_SERVER_WORKERS', 'BCRYPT_ROUNDS', 'LOG_CHANNEL', 'LOG_STACK', // 'LOG_DEPRECATIONS_CHANNEL', 'LOG_LEVEL', 'DB_CONNECTION', // 'DB_HOST', // 'DB_PORT', // 'DB_DATABASE', // 'DB_USERNAME', // 'DB_PASSWORD', 'SESSION_DRIVER', 'SESSION_LIFETIME', 'SESSION_ENCRYPT', 'SESSION_PATH', // 'SESSION_DOMAIN', 'BROADCAST_CONNECTION', 'FILESYSTEM_DISK', 'QUEUE_CONNECTION', 'CACHE_STORE', 'MEMCACHED_HOST', 'REDIS_CLIENT', 'REDIS_HOST', // 'REDIS_PASSWORD', 'REDIS_PORT', 'MAIL_MAILER', // 'MAIL_SCHEME', 'MAIL_HOST', 'MAIL_PORT', // 'MAIL_USERNAME', // 'MAIL_PASSWORD', 'MAIL_FROM_ADDRESS', 'MAIL_FROM_NAME', // 'AWS_ACCESS_KEY_ID', // 'AWS_SECRET_ACCESS_KEY', 'AWS_DEFAULT_REGION', // 'AWS_BUCKET', 'AWS_USE_PATH_STYLE_ENDPOINT', 'VITE_APP_NAME', // Add More Variables as needed ], /* |-------------------------------------------------------------------------- | Directory Permissions Check |-------------------------------------------------------------------------- | | These directories must be writable for proper application functioning. | Recommended permissions: | - 0775 for storage and cache directories (owner and group can write) | - 0777 only if absolutely necessary (less secure) | */ 'directories_to_check' => [ [ 'path' => storage_path(), 'required_permission' => 755, ], [ 'path' => storage_path('logs'), 'required_permission' => 755, ], [ 'path' => storage_path('framework'), 'required_permission' => 755, ], [ 'path' => storage_path('framework/sessions'), 'required_permission' => 755, ], [ 'path' => storage_path('framework/views'), 'required_permission' => 755, ], [ 'path' => base_path('bootstrap/cache'), 'required_permission' => 755, ], // Add more directories as needed ], /* |-------------------------------------------------------------------------- | File Existence Check |-------------------------------------------------------------------------- | | These files must exist and be readable for the application to function | properly. Common examples include SSL certificates, OAuth keys, and | configuration files. You can optionally enforce specific permissions. | | Example: | [ | 'path' => storage_path('keys/private.pem'), | 'required_permission' => 600, | 'check_permissions' => true, | ], | | */ 'files_to_check' => [ [ 'path' => base_path('.env'), ], ], ];
Command Output Example
When you run the command, you will see output similar to this:
┌──────────────────────────────────────────────────────────────┐
│ 🩺 Laravel Environment Doctor - System Diagnosis │
└──────────────────────────────────────────────────────────────┘
Checking your application environment configuration and permissions...
📦 ENVIRONMENT VARIABLES CHECK
Verifying required .env variables are set
+--------+-------------------------+
| Status | Message |
+--------+-------------------------+
| ✓ PASS | ✅ APP_NAME is set |
| ✓ PASS | ✅ APP_ENV is set |
| ✓ PASS | ✅ APP_KEY is set |
| ✓ PASS | ✅ DB_CONNECTION is set |
| ✓ PASS | ✅ DB_HOST is set |
| ✓ PASS | ✅ DB_DATABASE is set |
| ✓ PASS | ✅ DB_USERNAME is set |
+--------+-------------------------+
📁 DIRECTORY PERMISSIONS CHECK
Verifying directory permissions and writability
+--------+-----------------------------------------------------------------------------------------------------------------------------+
| Status | Message |
+--------+-----------------------------------------------------------------------------------------------------------------------------+
| ✓ PASS | ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/storage is writable (Permissions: 755) |
| ✓ PASS | ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/storage/logs is writable (Permissions: 755) |
| ✓ PASS | ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/storage/framework is writable (Permissions: 755) |
| ✓ PASS | ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/storage/framework/sessions is writable (Permissions: 755) |
| ✓ PASS | ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/storage/framework/views is writable (Permissions: 755) |
| ✓ PASS | ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/bootstrap/cache is writable (Permissions: 755) |
+--------+-----------------------------------------------------------------------------------------------------------------------------+
📄 FILE EXISTENCE CHECK
Verifying required files exist and are accessible
+--------+----------------------------------------------------------------+
| Status | Message |
+--------+----------------------------------------------------------------+
| ✓ PASS | ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/.env exists and is readable (Permissions: 644) |
+--------+----------------------------------------------------------------+
┌───────────────────────────────────┐
│ 🩺 DIAGNOSIS SUMMARY │
├───────────────────────────────────┤
│ Total checks performed: 14 │
│ Issues found: 0 │
│ Success rate: 100% │
└───────────────────────────────────┘
🎉 Excellent! Your environment is perfectly configured!
Log Example
You can also log the results to a file by using the --log option and it will be logged to specified log file in the config file. The log file will contain detailed information about the checks performed, including any issues found and their resolutions.
[2025-05-26 06:35:44] local.INFO: [EnvDoctor] ---- ENVIRONMENT VARIABLES CHECK ---- [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ APP_NAME is set [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ APP_ENV is set [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ APP_KEY is set [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ DB_CONNECTION is set [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ DB_HOST is set [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ DB_DATABASE is set [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ DB_USERNAME is set [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ---- DIRECTORY PERMISSIONS CHECK ---- [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/storage is writable (Permissions: 755) [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/storage/logs is writable (Permissions: 755) [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/storage/framework is writable (Permissions: 755) [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/storage/framework/sessions is writable (Permissions: 755) [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/storage/framework/views is writable (Permissions: 755) [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/bootstrap/cache is writable (Permissions: 755) [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ---- FILE EXISTENCE CHECK ---- [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ✓ PASS: ✅ /Users/dipeshkhanal/projects/Mantra Ideas/OSS/laravelEnvDoctor/.env exists and is readable (Permissions: 644) [2025-05-26 06:35:44] local.INFO: [EnvDoctor] ----- DIAGNOSIS SUMMARY ----- [2025-05-26 06:35:44] local.INFO: [EnvDoctor] Total checks performed: 14 [2025-05-26 06:35:44] local.INFO: [EnvDoctor] Issues found: 0 [2025-05-26 06:35:44] local.INFO: [EnvDoctor] Success rate: 100%
License
Author
Support
For support, email dipeshkhanal79[at]gmail[dot]com.
mantraideas/laravel-env-doctor 适用场景与选型建议
mantraideas/laravel-env-doctor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.29k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2025 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mantraideas/laravel-env-doctor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mantraideas/laravel-env-doctor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 18
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-26