定制 jameswmcnab/config-yaml 二次开发

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

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

jameswmcnab/config-yaml

最新稳定版本:v3.0.0

Composer 安装命令:

composer require jameswmcnab/config-yaml

包简介

A simple YAML config file loader for Laravel, taking inspiration from illuminate/config.

README 文档

README

This package is abandoned and no longer maintained. The author suggests using the pragmarx/yaml package instead.

YAML Config Loader for Laravel

Build Status

This provides simple YAML config loading to Laravel. It takes a lot of inspiration from the illuminate/config package and uses the Symfony YAML parser.

This is not a replacement for the built-in PHP config file system in Laravel but is intended as an extra 'layer' of configuration. This allows you to have one or more Ruby-like config.yaml files containing user-configurable config for your application.

By default the package assumes your YAML files are in the base_path() directory, but you can customise this by publishing the package config file (config-yaml.php) to your application and changing the yaml_path key.

Installation

Installation is via Composer:

$ composer require jameswmcnab/config-yaml

Publish package config (optional)

If you want to customise the package config, publish the package config then edit the newly created config/config-yaml.php file:

$ php artisan vendor:publish --provider=ConfigYamlServiceProvider

Usage

Example YAML file:

# Example YAML config.yaml file
app:
  name: "Great App"
  version: 1.0.2

log:
  dir: /var/log/vendor/app
  level: debug

database:
  adapter: mysql
  database: app_live
  username: user
  password: password

Using the facade

Note: Remember to register the facade in your app.php config.

ConfigYaml::get('config.database.adapter'); // mysql

Using dependency injection

If you don't want to use the facade just directly inject Jameswmcnab\ConfigYaml\RepositoryInterface wherever dependency injection is supported and use it directly:

<?php

namespace App\Foo;

use Jameswmcnab\ConfigYaml\RepositoryInterface;

class FooBar
{
    /**
     * @var RepositoryInterface
     */
    private $yamlConfig;

    /**
     * FooBar constructor.
     *
     * @param RepositoryInterface $yamlConfig
     */
    public function __construct(RepositoryInterface $yamlConfig)
    {
        $this->yamlConfig = $yamlConfig;
    }

    /**
     * @return array|string
     */
    private function getDatabaseAdapter()
    {
        return $this->yamlConfig->get('config.database.adapter');  // mysql
    }
}

Running Tests

To run the package tests:

$ vendor/bin/phpspec run
$ vendor/bin/phpunit

jameswmcnab/config-yaml 适用场景与选型建议

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

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

围绕 jameswmcnab/config-yaml 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-15