Yaml Configuration support for CakePHP 3

Overview

Yaml for CakePHP 3

implements most of the YAML 1.2 specification using Symfony Yaml Component to CakePHP 3 for parsing config files

Requirements

The 3.0 branch has the following requirements:

  • CakePHP 3.0.0 or greater.

Installation

  • Install the plugin with composer from your CakePHP Project's ROOT directory (where composer.json file is located)
php composer.phar require chobo1210/yaml "dev-master"

OR add this lines to your composer.json

"require": {
  "chobo1210/Yaml": "dev-master"
}

And run php composer.phar update

then add this lines to your config/bootstrap.php

use Yaml\Configure\Engine\YamlConfig;

try {
  Configure::config('yaml', new YamlConfig());
  Configure::load('your_file', 'yaml');
} catch (\Exception $e) {
  die('Unable to load config/your_file.yml.');
}

your file must be in the config/ directory replace your_file with the name of your YAML file without the extension

Usage

if you want to use the plugin Shell to convert your current config add the lines to config/bootstrap.php

Plugin::load('Yaml');

then in your Console or Terminal type :

bin/cake convert

Optionally you can set the name of your YAML file ( without the extension ) default is : app.yml

bin/cake convert your_file_name

the file will be create in your config/ directory.

Example

debug: true

Asset:
  timestamp: true

# Default Database Connection informations
default_configuration: &default_configuration
  className: Cake\Database\Connection
  driver: Cake\Database\Driver\Mysql
  persistent: false
  host: localhost
  login: root
  password: secret
  prefix: false
  encoding: utf8
  timezone: +01:00
  cacheMetadata: true
  quoteIdentifiers: false  



# Datasources
Datasources:
  # Default datasource
  default: 
    <<: *default_configuration
    database: my_database
  # PHPUnit tests datasource
  test:
    <<: *default_configuration
    database: my_database_test



# Email Configuration
EmailTransport:
  default:
      className: Mail
      host: localhost
      port: 1025
      timeout: 30
      # username: user
      # password: secret
      client: null
      tls: null
Email:
  default:
      transport: default
      from: [email protected]
      cherset: utf-8
      headerCharset: utf-8   
You might also like...
The Yaml component loads and dumps YAML files.

Yaml Component The Yaml component loads and dumps YAML files. Resources Documentation Contributing Report issues and send Pull Requests in the main Sy

[READ-ONLY] A flexible, lightweight and powerful Object-Relational Mapper for PHP, implemented using the DataMapper pattern. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP ORM The CakePHP ORM provides a powerful and flexible way to work with relational databases. Using a datamapper pattern the ORM allows you to m

Cakephp-book allows you to search in the official CakePHP documentation directly from the console.

CakeDC/Book plugin for CakePHP cakephp-book allows you to search in the official CakePHP documentation directly from the console. Requirements CakePHP

A sample CakePHP api application using CakeDC/cakephp-api and swoole as server

CakePHP Application Skeleton composer create-project --prefer-dist cakephp/app Added sample data using https://github.com/annexare/Countries Created m

Quickly and easily expose Doctrine entities as REST resource endpoints with the use of simple configuration with annotations, yaml, json or a PHP array.

Drest Dress up doctrine entities and expose them as REST resources This library allows you to quickly annotate your doctrine entities into restful res

A better YAML configuration file management virion for PocketMine-MP 4

BetterConfig WARNING: This virion is under development and haven't been tested. Do not use this virion unless you know what you're doing. Contribution

Pico disk, Not need any database, support html5, support mp3, mp4, support streaming media, support AriaNg
Pico disk, Not need any database, support html5, support mp3, mp4, support streaming media, support AriaNg

Nano netdisk, Now changed to pico disk. Pico disk,does not need any database, support html5, support mp3, mp4, support streaming media, support AriaNg.

World countries in JSON, CSV, XML and Yaml. Any help is welcome!

World countries in JSON, CSV, XML and YAML. Countries data This repository contains a list of world countries, as defined by ISO Standard 3166-1, in J

Phalcon Routering for Yaml

Phalcon Router for Yaml Version PHP: 7.0.x, 7.1.x, 7.2.x Phalcon: 3.x Composer { "require": { "ienaga/phalcon-router-for-yaml": "2.*"

phalcon config loader for yaml

Phalcon Config Loarder for Yaml Loads all the yml in the directory of the app/config. Version PHP: 7.0.x, 7.1.x, 7.2.x Phalcon: 3.x Composer { "r

Silverstripe-populate - Populate your database through YAML files

Populate Module This module provides a way to populate a database from YAML fixtures and custom classes. For instance, when a building a web applicati

Read and write OpenAPI 3.0.x YAML and JSON files and make the content accessible in PHP objects.

php-openapi Read and write OpenAPI 3.0.x YAML and JSON files and make the content accessible in PHP objects. It also provides a CLI tool for validatin

A compact command line utility for checking YAML file syntax

A compact command line utility for checking YAML file syntax. Uses the parsing facility of the Symfony Yaml Component.

Parses YAML files and adds them to Slim's config application instance method.

Slim Config - YAML Parses YAML files and adds them into Slim's config singleton. Uses Symfony's YAML Component to parse files (http://github.com/symfo

Sync Wordpress Pages and Posts (even custom post types + fields) from static Markdown + YAML files

Sync Markdown Files to WordPress Posts and Pages Static site generators let you use a revision-controlled tree of markdown files to make a site, but d

Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files
Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files

Icinga Web 2 Fileshipper module The main purpose of this module is to extend Icinga Director using some of it's exported hooks. Based on them it offer

GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer...
GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer...

Setup PHP in GitHub Actions Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in GitHub

GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer...
GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer...

Setup PHP in GitHub Actions Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in GitHub

This library extends the 'League OAuth2 Client' library to provide OpenID Connect Discovery support for supporting providers that expose a .well-known configuration endpoint.

OpenID Connect Discovery support for League - OAuth 2.0 Client This library extends the League OAuth2 Client library to provide OpenID Connect Discove

Comments
  • CakePHP 3 dev dependency

    CakePHP 3 dev dependency

    The plugin has cakephp/cakephp: 3.0.*-dev as a dependency, which causes problems when trying to use the stable version of CakePHP 3. It should just have cakephp/cakephp: ~3.0 as a dependency.

    opened by btaens 3
  • Update yaml requirement to 2.8|3.0 so it is not in conflict with robmorgan/phinx

    Update yaml requirement to 2.8|3.0 so it is not in conflict with robmorgan/phinx

    When I tried to install your plugin with composer it gave me conclusion: remove symfony/yaml v3.0.1 which is required by robmorgan/phinx, the lib used by cakephp. I think you need to update your composer.json file with new version of yaml.

    With Yaml::parse you now need to file_get_contents first as parameter should be string, not file. I have also added some doc to pass cake code sniffer

    opened by LubosRemplik 0
  • Autoloading?

    Autoloading?

    I'm not using this plugin yet, but I have a suggestion. You said the following at the README:

    then add this lines to your config/bootstrap.php use Yaml\Configure\Engine\YamlConfig;

    try {
      Configure::config('yaml', new YamlConfig());
      Configure::load('your_file', 'yaml');
    } catch (\Exception $e) {
      die('Unable to load config/your_file.yml.');
    }
    

    Please be that smart to put that stuff in your config/bootstrap.php of the plugin, and load the plugin with:

    // shell
    $ bin/cake plugin load -b Yaml
    
    // by yourself
    Plugin::load('Yaml', ['bootstrap' => true]);
    

    This makes the plugin easier to use.

    Try to search in the config directory for .yaml files or create a convention that the yaml-file should be called app.yaml or something...

    Greetz

    Bob

    enhancement 
    opened by bobmulder 0
Releases(1.1)
Owner
Borhaneddine Guemidi
Borhaneddine Guemidi
Simple yet expressive schema-based configuration library for PHP apps

league/config helps you define nested configuration arrays with strict schemas and access configuration values with dot notation.

The League of Extraordinary Packages 269 Nov 30, 2022
LOAD is a PHP library for configuration loading to APCu

LOAD LOAD is a PHP library for configuration loading to APCu Sources Available sources for configuration loading are: PHP file Consul Environment vari

Beat Labs 4 Jan 18, 2022
Config is a file configuration loader that supports PHP, INI, XML, JSON, YML, Properties and serialized files and string

Config Config is a file configuration loader that supports PHP, INI, XML, JSON, YML, Properties and serialized files and strings. Requirements Config

Hassan Khan 948 Nov 27, 2022
zend-config is designed to simplify access to configuration data within applications

zend-config is designed to simplify access to configuration data within applications

Zend Framework 89 Jan 13, 2022
Map request on your DTO object with zero configuration.

Map request on your DTO object with zero configuration. Install composer require prugala/symfony-request-dto Usage Create a DTO that implements the in

Piotr Rugala 12 Nov 17, 2022
[READ-ONLY] Collection library in CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Collection Library The collection classes provide a set of tools to manipulate arrays or Traversable objects. If you have ever used underscore

CakePHP 84 Sep 28, 2022
[READ-ONLY] The event dispatcher library for CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Event Library This library emulates several aspects of how events are triggered and managed in popular JavaScript libraries such as jQuery: An

CakePHP 21 Oct 6, 2022
[READ-ONLY] Validation library from CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Validation Library The validation library in CakePHP provides features to build validators that can validate arbitrary arrays of data with eas

CakePHP 39 Oct 11, 2022
[READ-ONLY] CakePHP Utility classes such as Inflector, Text, Hash, Security and Xml. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Utility Classes This library provides a range of utility classes that are used throughout the CakePHP framework What's in the toolbox? Hash A

CakePHP 112 Feb 15, 2022
[READ-ONLY] Easy to use Caching library with support for multiple caching backends. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Caching Library The Cache library provides a Cache service locator for interfacing with multiple caching backends using a simple to use interf

CakePHP 49 Sep 28, 2022