定制 zeyad82/laravel-envx 二次开发

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

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

zeyad82/laravel-envx

Composer 安装命令:

composer require zeyad82/laravel-envx

包简介

Laravel custom env with validation

README 文档

README

Laravel Envx is a custom php environment file as an array so that it can have associative and multidimensional arrays with validation rules in order to avoid any unexpected behaviour especially if there are several instances of the project. This has been tested with laravel 5.6 and 5.7.

Highlights

  • Make sure you don't go live without all required envx.php variables and without the correct values
  • Validate envx.php variables using the Laravel Validator by defining rules in config/envx-validator.php
  • Custom validation rule required_ifany to apply rules to an atrribute if another array attribute has a given value

Usage

Just like laravel env => envx('attribute', 'default')

Installation

Via Composer:

    composer require zeyad82/laravel-envx

If you don't use auto-discovery, add the service provider your config/app.php:

    Zeyad82\LaravelEnvx\LaravelEnvxServiceProvider::class,

Publish configuration file

    php artisan vendor:publish --tag="laravel-envx"

This will publish config/envx-validator.php and envx.example.php then run

    cp envx.example.php envx.php

If you will have different envx.php, add envx.php to .gitignore in your project root

If you will use envx in config files, the only way I found is to append the follwing to bootstrap/app.php after ExceptionHandler

$app->singleton('envx', function ($app) {
    return new Zeyad82\LaravelEnvx\EnvxService;
});

Example configuration file

<?php
// config/envx-validator.php

return [
    'ARRAY'         => 'required|array',
    'ARRAY.*'       => 'required|in:val1,val2,val3',

    'ATTRIBUTE'     => 'required_ifany:ARRAY,val1|url',
]

Example envx.php file

<?php

return [
    'ARRAY'                     => 'required|array',
    'ARRAY.*'                   => 'required|in:val1,val2,val3',

    'ATTRIBUTE'                 => 'required_ifany:ARRAY,val1|url',
];

Screenshot

Command Line

Screenshot

Browser

Screenshot

Security

If you discover any security related issues, please email zeyad82@yahoo.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固