2017 © Pedro PelĂĄez
 

library laravel-yaml

Laravel ServiceProvider for using YAML configuration files

image

theofidry/laravel-yaml

Laravel ServiceProvider for using YAML configuration files

  • Wednesday, August 24, 2016
  • by theofidry
  • Repository
  • 1 Watchers
  • 5 Stars
  • 4,851 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 5 % Grown

The README.md

Laravel Yaml ServiceProvider

Package version Build Status SensioLabsInsight Dependency Status Scrutinizer Code Quality Code Coverage License, (*1)

A simple Laravel library to declare your parmeters and services in Yaml like in [Symfony][2]:, (*2)

# resources/providers/services.yml

services:
    dummy_service:
        class: App\Services\DummyService
        alias: dummy
        arguments:
            - %app.url%
            - %app.env%

instead of:, (*3)

# app/Providers/AppServiceProvider.php

//...
public function register()
{
    $this->app->singleton(
        'dummy_service',
        function ($app) {
            $url = env('APP_URL');
            $env = env('APP_ENV');

            return new \App\Services\DummyService($url, $env);
        }
    );
}

Documentation

  1. Disclaimer: why using this library?
  2. Install
  3. Everything about parameters
    1. YAML vs PHP
    2. Refering to another value
    3. Refering to an environment value
    4. Refering to constants
    5. Overriding values
    6. Environment dependent parameters
  4. Service declaration
    1. Simple services
    2. Factories
    3. Decorating services
  5. Custom file organisation
    1. Import other files
    2. Use your own provider

Install

You can use Composer to install the bundle to your project:, (*4)

composer require theofidry/laravel-yaml

Then, add the provider Fidry\LaravelYaml\Provider\DefaultExtensionProvider to your application providers:, (*5)

<?php
// config/app.php

'providers' => [
    // ...
    \Fidry\LaravelYaml\Provider\DefaultExtensionProvider::class,
];

Usage

See how to declare and use parameters and services!, (*6)

By convention, you should have the following structure:, (*7)

resources/
    providers/
        parameters.yml
        parameters_testing.yml
        services.yml

The parameters.yml should contain all of your application parameters values:, (*8)

# resources/providers/parameters.yml

parameters:
    my_parameter: parameter_value

Depending of your environment, a second parameters file will be loaded. For example, if your application environment (by default defined by the environment variable APP_ENV in your .env file) is 'testing' or 'production', the library will try to load the parameters_testing.yml or parameters_production.yml file., (*9)

Then services.yml should contain all your service definitions., (*10)

See more., (*11)

Credits

This bundle is developed by Théo FIDRY., (*12)

The Versions

24/08 2016

dev-master

9999999-dev

Laravel ServiceProvider for using YAML configuration files

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel service yaml provider

14/03 2016

v1.0.0-beta.2

1.0.0.0-beta2

Laravel ServiceProvider for using YAML configuration files

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel service yaml provider

07/03 2016

v1.0.0-beta.1

1.0.0.0-beta1

Laravel ServiceProvider for using YAML configuration files

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel service yaml provider

07/03 2016

v1.0.0-beta.0

1.0.0.0-beta0

Laravel ServiceProvider for using YAML configuration files

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel service yaml provider