2017 © Pedro Peláez
 

library config-yaml

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

image

jameswmcnab/config-yaml

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

  • Thursday, June 21, 2018
  • by jameswmcnab
  • Repository
  • 1 Watchers
  • 1 Stars
  • 4,004 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 8 Versions
  • 1 % Grown

The README.md

Abandoned

This package is abandoned and no longer maintained. The author suggests using the pragmarx/yaml package instead., (*1)

YAML Config Loader for Laravel

Build Status, (*2)

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., (*3)

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., (*4)

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., (*5)

Installation

Installation is via Composer:, (*6)

$ 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:, (*7)

$ php artisan vendor:publish --provider=ConfigYamlServiceProvider

Usage

Example YAML file:, (*8)

``` yaml, (*9)

Example YAML config.yaml file

app: name: "Great App" version: 1.0.2, (*10)

log: dir: /var/log/vendor/app level: debug, (*11)

database: adapter: mysql database: app_live username: user password: password ````, (*12)

Using the facade

Note: Remember to register the facade in your app.php config., (*13)

``` php ConfigYaml::get('config.database.adapter'); // mysql, (*14)


#### 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 <?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:, (*15)

bash $ vendor/bin/phpspec run $ vendor/bin/phpunit, (*16)

The Versions

21/06 2018

dev-develop

dev-develop

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

  Sources   Download

MIT

The Requires

 

The Development Requires

21/06 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

21/06 2018

v3.0.0

3.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

29/05 2017

v2.1.1

2.1.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

08/08 2016

v2.1.0

2.1.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

02/03 2015

v2.0.0

2.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

16/02 2015

1.0.x-dev

1.0.9999999.9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

16/02 2015

v1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires